Permalink
Browse files

Selector: Properly implement :enabled/:disabled for select contents

SemVer patch
Fixes gh-387
Ref jquery/jquery#3263

Closes gh-388
1 parent 281a6ff commit ff1c731962c9a24814189ca992eac0d94b58ecac @gibson042 gibson042 committed Jul 30, 2016
Showing with 14 additions and 4 deletions.
  1. +1 −1 dist/sizzle.js
  2. +1 −1 dist/sizzle.min.js
  3. +1 −1 dist/sizzle.min.map
  4. +1 −1 src/sizzle.js
  5. +10 −0 test/unit/selector.js
View
@@ -179,7 +179,7 @@ var i,
disabledAncestor = addCombinator(
function( elem ) {
- return elem.disabled === true;
+ return elem.disabled === true && ("form" in elem || "label" in elem);
},
{ dir: "parentNode", next: "legend" }
);
View
Oops, something went wrong.
View
Oops, something went wrong.
View
@@ -179,7 +179,7 @@ var i,
disabledAncestor = addCombinator(
function( elem ) {
- return elem.disabled === true;
+ return elem.disabled === true && ("form" in elem || "label" in elem);
},
{ dir: "parentNode", next: "legend" }
);
View
@@ -1088,6 +1088,16 @@ QUnit.test("pseudo - form", function( assert ) {
QUnit.test("pseudo - :(dis|en)abled, explicitly disabled", function( assert ) {
assert.expect( 2 );
+ // Set a meaningless disabled property on a common ancestor
+ var container = document.getElementById( "disabled-tests" );
+ container.disabled = true;
+
+ // Support: IE 6 - 11
+ // Unset the property where it is not meaningless
+ if ( document.getElementById( "enabled-input" ).isDisabled ) {
+ container.disabled = undefined;
+ }
+
t(
"Explicitly disabled elements",
"#enabled-fieldset :disabled",

0 comments on commit ff1c731

Please sign in to comment.