#8586 closed bug (worksforme)
contents().hide() results in javascript error, does not hide text nodes
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | 1.next |
Component: | effects | Version: | 1.5.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
If you have a table cell with whitespace or text, and you try to do:
$cell.contents().hide();
you will get a Javascript error:
Cannot set property 'display' of undefined
The reason is this loop on line 7486 of jquery-1.5.1.js:
for ( i = 0; i < j; i++ ) { this[i].style.display = "none"; }
Incidentally, I tried simply adding a check to avoid the error:
for ( i = 0; i < j; i++ ) { if (this[i] != undefined && this[i].style != undefined) this[i].style.display = "none"; }
This prevents the error from occurring, however, it doesn't solve the problem, since the text node is not hidden.
Change History (4)
comment:1 follow-up: 2 Changed 12 years ago by
Owner: | set to [email protected]… |
---|---|
Status: | new → pending |
comment:2 Changed 12 years ago by
Status: | pending → new |
---|
Replying to addyosmani:
Thanks for submitting a ticket to the jQuery Bug Tracker. So that we can assist you further, please also provide us with a minimal test case on http://jsfiddle.net that reproduces the issue you're experiencing.
comment:3 follow-up: 4 Changed 12 years ago by
Component: | unfiled → effects |
---|---|
Resolution: | → worksforme |
Status: | new → closed |
This is not a jQuery "bug", as hide() operates on matched elements (contents returns elements, text nodes and comment nodes), which is documented here: http://api.jquery.com/hide
The correct way to hide cell "contents"
comment:4 Changed 12 years ago by
Replying to rwaldron:
This is not a jQuery "bug", as hide() operates on matched elements (contents returns elements, text nodes and comment nodes), which is documented here: http://api.jquery.com/hide
The correct way to hide cell "contents"
I understand that there are other ways to hide contents that work. I believe the fact that contents().hide() can generate a javascript error is a problem. Even if fixing the effect isn't a priority, I would expect it to hide what it can and ignore the rest without error.
Thanks for submitting a ticket to the jQuery Bug Tracker. So that we can assist you further, please also provide us with a minimal test case on http://jsfiddle.net that reproduces the issue you're experiencing.