Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#14508 closed bug (notabug)

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.

Change History (6)

comment:1 Changed 6 years ago by anonymous

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.

comment:2 Changed 6 years ago by Rick Waldron

Confirmed. This is really bad.

comment:3 Changed 6 years ago by Rick Waldron

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.

comment:4 Changed 6 years ago by timmywil

Resolution: notabug
Status: newclosed

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".

comment:5 in reply to:  4 Changed 5 years ago by anonymous

Replying to 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.

comment:6 Changed 5 years ago by dmethvin

How about "Garbage in, garbage out" then?

Note: See TracTickets for help on using tickets.