Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
3f66e928
Commit
3f66e928
authored
Dec 17, 2012
by
Timmy Willison
Committed by
Rick Waldron
Dec 31, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.0: Remove getSetAttribute and getSetInput and oldIE attroperties hooks
parent
d50c18e6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
126 deletions
+6
-126
attributes.js
src/attributes.js
+6
-121
support.js
src/support.js
+0
-5
No files found.
src/attributes.js
View file @
3f66e928
...
@@ -3,10 +3,7 @@ var nodeHook, boolHook,
...
@@ -3,10 +3,7 @@ var nodeHook, boolHook,
rreturn
=
/
\r
/g
,
rreturn
=
/
\r
/g
,
rfocusable
=
/^
(?:
input|select|textarea|button|object
)
$/i
,
rfocusable
=
/^
(?:
input|select|textarea|button|object
)
$/i
,
rclickable
=
/^
(?:
a|area
)
$/i
,
rclickable
=
/^
(?:
a|area
)
$/i
,
rboolean
=
/^
(?:
checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped
)
$/i
,
rboolean
=
/^
(?:
checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped
)
$/i
;
ruseDefault
=
/^
(?:
checked|selected
)
$/i
,
getSetAttribute
=
jQuery
.
support
.
getSetAttribute
,
getSetInput
=
jQuery
.
support
.
input
;
jQuery
.
fn
.
extend
({
jQuery
.
fn
.
extend
({
attr
:
function
(
name
,
value
)
{
attr
:
function
(
name
,
value
)
{
...
@@ -349,22 +346,12 @@ jQuery.extend({
...
@@ -349,22 +346,12 @@ jQuery.extend({
propName
=
jQuery
.
propFix
[
name
]
||
name
;
propName
=
jQuery
.
propFix
[
name
]
||
name
;
// Boolean attributes get special treatment (#10870)
// Boolean attributes get special treatment (#10870)
// Set corresponding property to false for boolean attributes
if
(
rboolean
.
test
(
name
)
)
{
if
(
rboolean
.
test
(
name
)
)
{
// Set corresponding property to false for boolean attributes
elem
[
propName
]
=
false
;
// Also clear defaultChecked/defaultSelected (if appropriate) for IE<8
if
(
!
getSetAttribute
&&
ruseDefault
.
test
(
name
)
)
{
elem
[
jQuery
.
camelCase
(
"default-"
+
name
)
]
=
elem
[
propName
]
=
false
;
}
else
{
elem
[
propName
]
=
false
;
}
// See #9699 for explanation of this approach (setting first, then removal)
}
else
{
jQuery
.
attr
(
elem
,
name
,
""
);
}
}
elem
.
removeAttribute
(
getSetAttribute
?
name
:
propN
ame
);
elem
.
removeAttribute
(
n
ame
);
}
}
}
}
},
},
...
@@ -456,26 +443,7 @@ jQuery.extend({
...
@@ -456,26 +443,7 @@ jQuery.extend({
// Hook for boolean attributes
// Hook for boolean attributes
boolHook
=
{
boolHook
=
{
get
:
function
(
elem
,
name
)
{
get
:
function
(
elem
,
name
)
{
var
return
elem
.
getAttribute
(
name
)
!==
null
?
// Use .prop to determine if this attribute is understood as boolean
prop
=
jQuery
.
prop
(
elem
,
name
),
// Fetch it accordingly
attr
=
typeof
prop
===
"boolean"
&&
elem
.
getAttribute
(
name
),
detail
=
typeof
prop
===
"boolean"
?
getSetInput
&&
getSetAttribute
?
attr
!=
null
:
// oldIE fabricates an empty string for missing boolean attributes
// and conflates checked/selected into attroperties
ruseDefault
.
test
(
name
)
?
elem
[
jQuery
.
camelCase
(
"default-"
+
name
)
]
:
!!
attr
:
// fetch an attribute node for properties not recognized as boolean
elem
.
getAttributeNode
(
name
);
return
detail
&&
detail
.
value
!==
false
?
name
.
toLowerCase
()
:
name
.
toLowerCase
()
:
undefined
;
undefined
;
},
},
...
@@ -483,96 +451,13 @@ boolHook = {
...
@@ -483,96 +451,13 @@ boolHook = {
if
(
value
===
false
)
{
if
(
value
===
false
)
{
// Remove boolean attributes when set to false
// Remove boolean attributes when set to false
jQuery
.
removeAttr
(
elem
,
name
);
jQuery
.
removeAttr
(
elem
,
name
);
}
else
if
(
getSetInput
&&
getSetAttribute
||
!
ruseDefault
.
test
(
name
)
)
{
// IE<8 needs the *property* name
elem
.
setAttribute
(
!
getSetAttribute
&&
jQuery
.
propFix
[
name
]
||
name
,
name
);
// Use defaultChecked and defaultSelected for oldIE
}
else
{
}
else
{
elem
[
jQuery
.
camelCase
(
"default-"
+
name
)
]
=
elem
[
name
]
=
true
;
elem
.
setAttribute
(
name
,
name
)
;
}
}
return
name
;
return
name
;
}
}
};
};
// fix oldIE value attroperty
if
(
!
getSetInput
||
!
getSetAttribute
)
{
jQuery
.
attrHooks
.
value
=
{
get
:
function
(
elem
,
name
)
{
var
ret
=
elem
.
getAttributeNode
(
name
);
return
jQuery
.
nodeName
(
elem
,
"input"
)
?
// Ignore the value *property* by using defaultValue
elem
.
defaultValue
:
ret
&&
ret
.
specified
?
ret
.
value
:
undefined
;
},
set
:
function
(
elem
,
value
,
name
)
{
if
(
jQuery
.
nodeName
(
elem
,
"input"
)
)
{
// Does not return so that setAttribute is also used
elem
.
defaultValue
=
value
;
}
else
{
// Use nodeHook if defined (#1954); otherwise setAttribute is fine
return
nodeHook
&&
nodeHook
.
set
(
elem
,
value
,
name
);
}
}
};
}
// IE6/7 do not support getting/setting some attributes with get/setAttribute
if
(
!
getSetAttribute
)
{
// Use this for any attribute in IE6/7
// This fixes almost every IE6/7 issue
nodeHook
=
jQuery
.
valHooks
.
button
=
{
get
:
function
(
elem
,
name
)
{
var
ret
=
elem
.
getAttributeNode
(
name
);
return
ret
&&
(
name
===
"id"
||
name
===
"name"
||
name
===
"coords"
?
ret
.
value
!==
""
:
ret
.
specified
)
?
ret
.
value
:
undefined
;
},
set
:
function
(
elem
,
value
,
name
)
{
// Set the existing or create a new attribute node
var
ret
=
elem
.
getAttributeNode
(
name
);
if
(
!
ret
)
{
elem
.
setAttributeNode
(
(
ret
=
elem
.
ownerDocument
.
createAttribute
(
name
))
);
}
ret
.
value
=
value
+=
""
;
// Break association with cloned elements by also using setAttribute (#9646)
return
name
===
"value"
||
value
===
elem
.
getAttribute
(
name
)
?
value
:
undefined
;
}
};
// Set contenteditable to false on removals(#10429)
// Setting to empty string throws an error as an invalid value
jQuery
.
attrHooks
.
contenteditable
=
{
get
:
nodeHook
.
get
,
set
:
function
(
elem
,
value
,
name
)
{
nodeHook
.
set
(
elem
,
value
===
""
?
false
:
value
,
name
);
}
};
// Set width and height to auto instead of 0 on empty string( Bug #8150 )
// This is for removals
jQuery
.
each
([
"width"
,
"height"
],
function
(
i
,
name
)
{
jQuery
.
attrHooks
[
name
]
=
jQuery
.
extend
(
jQuery
.
attrHooks
[
name
],
{
set
:
function
(
elem
,
value
)
{
if
(
value
===
""
)
{
elem
.
setAttribute
(
name
,
"auto"
);
return
value
;
}
}
});
});
}
// Radios and checkboxes getter/setter
// Radios and checkboxes getter/setter
if
(
!
jQuery
.
support
.
checkOn
)
{
if
(
!
jQuery
.
support
.
checkOn
)
{
jQuery
.
each
([
"radio"
,
"checkbox"
],
function
()
{
jQuery
.
each
([
"radio"
,
"checkbox"
],
function
()
{
...
...
src/support.js
View file @
3f66e928
...
@@ -80,11 +80,6 @@ jQuery.support = (function() {
...
@@ -80,11 +80,6 @@ jQuery.support = (function() {
support
.
deleteExpando
=
false
;
support
.
deleteExpando
=
false
;
}
}
// Check if we can trust getAttribute("value")
input
=
document
.
createElement
(
"input"
);
input
.
setAttribute
(
"value"
,
""
);
support
.
input
=
input
.
getAttribute
(
"value"
)
===
""
;
// Check if an input maintains its value after becoming a radio
// Check if an input maintains its value after becoming a radio
input
.
value
=
"t"
;
input
.
value
=
"t"
;
input
.
setAttribute
(
"type"
,
"radio"
);
input
.
setAttribute
(
"type"
,
"radio"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment