Side navigation
#14508 closed bug (notabug)
Opened November 04, 2013 02:17PM UTC
Closed November 04, 2013 03:32PM UTC
Last modified December 07, 2013 01:11AM UTC
Apple iOS7 id based selectors with context can return elements outside context
Reported by: | anonymous | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.10.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
This problem was discovered in a jQuery Mobile app that has a selectors of the form $('#id', $.mobile.activePage). The results contain the element from both the active and inactive jQuery Mobile page DOM container element.
This behaviour isn't seen in previous iOS releases, or other browsers (IE9, Firefox 24, Chrome 30.x, Android [various versions]).
jsfiddle example demonstrating the behavior.
http://jsfiddle.net/DgfBt/7/ - Uses jQuery 1.9.1
http://jsfiddle.net/DgfBt/8/ - Uses jQuery 1.10.1 (latest jsfiddle had)
The jQuery Mobile issue for this is https://github.com/jquery/jquery-mobile/issues/6610, in case that is of additional help.
The app uses jQuery 1.9.1 and jQuery Mobile 1.3.1. Unfortunately that means if a jQuery patch was created to address this, we'd need a 1.9.1 based one, since jQuery Mobile 1.3 only supports up to jQuery 1.9.1.
Attachments (0)
Change History (6)
Changed November 04, 2013 02:23PM UTC by comment:1
Changed November 04, 2013 03:13PM UTC by comment:2
Confirmed. This is really bad.
Changed November 04, 2013 03:16PM UTC by comment:3
While reducing the case further, I realized the test case markup is invalid. IDs must be unique and having more than one element share an ID will result in unexpected behaviour. I'm not going to close this because I want Dave, Richard and Tim to look at it first.
Changed November 04, 2013 03:32PM UTC by comment:4
resolution: | → notabug |
---|---|
status: | new → closed |
Agreed, while the behavior is terribly inconsistent and should be reported to Apple, the HTML is invalid. There are several other unpredictable issues that arise when multiple elements have the same ID on a page, which has only further emboldened us to respond with, "We do not support invalid HTML".
Changed December 07, 2013 01:01AM UTC by comment:5
Replying to [comment:4 timmywil]:
Agreed, while the behavior is terribly inconsistent and should be reported to Apple, the HTML is invalid. There are several other unpredictable issues that arise when multiple elements have the same ID on a page, which has only further emboldened us to respond with, "We do not support invalid HTML".
"You shouldn't do that," is the worst kind of nonresponse. The fact remains that the documented function fails to work as described.
Changed December 07, 2013 01:11AM UTC by comment:6
How about "Garbage in, garbage out" then?
Forgot to mention that it is due to querySelectorAll() behavior changing in iOS7, which someone tracked down when looking into the jQuery Mobile issue mentioned above.