From 5ff208b23d8cf5a126906213ddaf281cfc4b9730 Mon Sep 17 00:00:00 2001
From: Richard Gibson
Date: Sat, 30 Jul 2016 01:08:19 -0400
Subject: [PATCH 1/3] Selector: Properly implement :enabled/:disabled for
select contents
SemVer patch
Fixes gh-382
Ref https://github.com/jquery/jquery/issues/3224
Ref 7999a01cf7bc92fb7d2951b4ad7442dbbd788e7f
---
dist/sizzle.js | 57 +++++++++++++++++++++++++++++--------------
dist/sizzle.min.js | 2 +-
dist/sizzle.min.map | 2 +-
src/sizzle.js | 55 ++++++++++++++++++++++++++++-------------
test/unit/selector.js | 17 +++++++++++++
5 files changed, 96 insertions(+), 37 deletions(-)
diff --git a/dist/sizzle.js b/dist/sizzle.js
index 0f4c3540..b4a75038 100644
--- a/dist/sizzle.js
+++ b/dist/sizzle.js
@@ -6,7 +6,7 @@
* Released under the MIT license
* http://jquery.org/license
*
- * Date: 2016-02-23
+ * Date: 2016-07-29
*/
(function( window ) {
@@ -465,26 +465,45 @@ function createButtonPseudo( type ) {
* @param {Boolean} disabled true for :disabled; false for :enabled
*/
function createDisabledPseudo( disabled ) {
- // Known :disabled false positives:
- // IE: *[disabled]:not(button, input, select, textarea, optgroup, option, menuitem, fieldset)
- // not IE: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
+
+ // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
return function( elem ) {
- // Check form elements and option elements for explicit disabling
- return "label" in elem && elem.disabled === disabled ||
+ // Only certain elements can match :enabled or :disabled
+ // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
+ // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
+ return "form" in elem && elem.disabled === false ?
+
+ // Check for inherited disabledness on relevant non-disabled elements:
+ // * listed form-associated elements in a disabled fieldset
+ // https://html.spec.whatwg.org/multipage/forms.html#category-listed
+ // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
+ // * option elements in a disabled optgroup
+ // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
+ // All such elements have a "form" property.
+
+ // Support: IE 6 - 11
+ // Use the isDisabled shortcut property, which already covers inheritance
+ elem.isDisabled === disabled ||
+
+ // Where there is no isDisabled, check ancestors manually
+ /* jshint -W018 */
+ elem.isDisabled !== !disabled && ( "label" in elem ?
+
+ // Option elements defer to a parent optgroup if present
+ ( elem.parentNode && "label" in elem.parentNode ?
+ elem.parentNode.disabled === disabled :
+ elem.disabled === disabled ) :
+
+ // All others defer to ancestor fieldsets if present
+ disabledAncestor( elem ) === disabled
+ ) :
+
+ // Try to winnow out elements that can't be disabled before trusting the property.
+ // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
+ // even exist on them, let alone have a boolean value.
"form" in elem && elem.disabled === disabled ||
-
- // Check non-disabled form elements for fieldset[disabled] ancestors
- "form" in elem && elem.disabled === false && (
- // Support: IE6-11+
- // Ancestry is covered for us
- elem.isDisabled === disabled ||
-
- // Otherwise, assume any non-