jquery/sizzle — pull request #81 by gibson042 (2011-11-16 21:31:59+00:00)
Title: Ticket 10799

`document.getElementsByName` doesn't behave as predictably as we'd all like it to. Sometimes, in quirks mode, IE limits the results to "form controls" (`INPUT`, `SELECT`, `TEXTAREA`, and other elements identified in [HTML4](http://www.w3.org/TR/html4/) as ascribing meaning to the `name` attribute). When that is the case, `jQuery("[name=*]")` (which is optimized with `getElementsByName`) behaves even *less* predictably... it will include elements of any tag name **if and only if** there are no "form controls" matching the selector. I made a [test case](http://jsbin.com/uyezin/2) that showcases this absolutely bizarre IE behavior.

What's more, `document.querySelectorAll` *does* work as expected, so the quirky behavior is also dependent upon its definition and the presence or absence of pseudo-selectors. And although workaround selectors are easy to write, it's also easy to get tripped up by non-obvious method implementations: `$current.has('[name=*]')`.

The bottom line is that we can only promise consistency by abandoning `document.getElementsByName` optimization of name selectors when it excludes elements from consideration. This pull request does precisely that.