Opened 12 years ago
Closed 12 years ago
#8821 closed bug (worksforme)
Javascript error is thrown in IE when executing closest(':visible')
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | selector | Version: | 1.5.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Javascript error in IE 8 when executing element.closest(':visible');
Condition to recreate the defect:
- browser: IE only (works fine on FF, Safari, Chrome)
- target html object does not exist
- ancestor of the element is not part of html DOM tree
- created by document.createElement("div") or
- child of element #abc which has been removed by $("#abc").empty()
Root cause:
property parentNode of the above ascestor element is different in different browser:
- FireFox: 3.6.12 null
- IE 8: an element with nodeName "#document-fragment" (value of parentElement is null)
Because jQuery uses following codes to get parent node in closest() method:
- cur = cur.parentNode;
And following codes to check whether the element is visible:
- (!jQuery.support.reliableHiddenOffsets && (elem.style.display | | jQuery.css( elem, "display" )) === "none")
Because the document fragment element does not have style property, exception will be thrown.
It is found in jQuery 1.4.4, and is also there in 1.5.2
Change History (3)
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 |
---|
Test case created: http://jsfiddle.net/Crane/Y6Ujk/
Test result (IE 6.0.2900)
- JS Error with jQuery 1.5.1
- Works fine with jQuery (edge) :-)
comment:3 Changed 12 years ago by
Component: | unfiled → selector |
---|---|
Priority: | undecided → low |
Resolution: | → worksforme |
Status: | new → closed |
If it's working on edge, then the issue is resolved. Closing.
Thanks for taking the time to contribute to the jQuery project! Please provide a reduced test case on http://jsFiddle.net that reproduces the issue experienced to help us assess your ticket!
Additionally, test against the
jQuery (edge)
version to ensure the issue still exists.