Skip to content

Commit

Permalink
Selector: Properly implement :enabled/:disabled for select contents
Browse files Browse the repository at this point in the history
SemVer patch
Fixes jquerygh-387
Ref jquery/jquery#3263

Closes jquerygh-388
  • Loading branch information
gibson042 committed Aug 8, 2016
1 parent 281a6ff commit ff1c731
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/sizzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
);
Expand Down
2 changes: 1 addition & 1 deletion dist/sizzle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/sizzle.min.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/sizzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
);
Expand Down
10 changes: 10 additions & 0 deletions test/unit/selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit ff1c731

Please sign in to comment.