Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8614513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:08:18+00:00 2026-06-12T05:08:18+00:00

Background: I am using QUnit to validate the creation of DOM elements in the

  • 0

Background:
I am using QUnit to validate the creation of DOM elements in the following manner (which has been working fine so far):

$actual = Mylibrary.createSomething();
$expected = $('<div........');
ok($actual[0].isEqualNode($expected[0]),'Node properly created');

More info on isEqualNode: MDN, W3

Issue:
I am having an issue comparing nodes when I use the jQuery's .hide() method because:

  • it produces style="display: none;" (no extra space after ;) with Firefox
  • it produces style="display: none; " (extra space after ;) with Chrome
  • isEqualNode considers that style="display: none;" is different than style="display: none; " (you can have attributes in different order and isEqualNode still considers nodes to be equal, but that extra space not).
  • when building $expected, I can only cater for 1 of the 2 situations.

Accordingly my tests end up always failing with Chrome or Firefox depending on which situation I choose to create $expected.

Here is a jsFiddle so that you can see what I mean

I could check if element is hidden with .is(':hidden') but that isn’t ideal to me because:

  • I can no longer compare whole set of DOM elements with .isEqualNode like I currently do and would have to write many individual tests to get an equivalent which will make my tests very extensive and hard to maintain.
  • I feel that by using a DOM method (i.e. isEqualNode) my tests are more robusts than if I used a jQuery method (e.g. .is(':hidden')) because my elements are generated with jQuery in the first place and having a jQuery-independent verification method will more likely spot problems.

Do you see the discrepancies with the way the jQuery‘s .hide() method generates the stype="display attribute as a bug/problem? (i.e. should I raise it on http://bugs.jquery.com/)?

Do you see a solution that would allow me comparing my nodes without using jQuery methods?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:08:20+00:00Added an answer on June 12, 2026 at 5:08 am

    From QUnit perspective perform the following check in order to see whether the element is hidden:

    equal(element.css('display'), 'none', 'element is not hidden');
    

    This eliminates the need for you to compare string differences. If you are not using jQuery then perform:

    equal(element.style.display, 'none', 'element is not hidden');
    

    If you would like to create some utility extensions to modularize your unit/interaction testing, then isEqualNode is not your best approach here. Better provide yourself with methods like:

    checkClass(element, cssClass)
    checkAttribute(element, attr, value)
    checkAttributeExists(element, attr)
    etc...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to ask, which method has been called whenever the user quit
Insert ( NSFetchedResultsChangeInsert )is working from my background thread, from that same thread, using
I am working on a service, which extends the Service class and using a
Background: Using Facebook PHP SDK v 2.1.2 cookieSupport = true App on Facebook has
How to get the following red boxes as background using only css and no
Background: Using unix, codeigniter from localhost. I'd like to run a controllers via a
Background Using boost and other similar libraries is the easiest way to find compiler
Background: Using jQuery 1.7 client side PHP server side Using json responses with json_encode
Background Using JavaScript, I need to sort a large JSON object based on a
How to make android icons with transparent background using eclipse.I know that we can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.