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
126d596b
Commit
126d596b
authored
Sep 18, 2013
by
Richard Gibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #14074: element id="nodeName". Close gh-1389.
parent
d0b8f9fa
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
22 deletions
+57
-22
data.js
src/data.js
+6
-6
accepts.js
src/data/accepts.js
+7
-7
aliased.html
test/data/core/aliased.html
+24
-0
core.js
test/unit/core.js
+7
-0
data.js
test/unit/data.js
+13
-9
No files found.
src/data.js
View file @
126d596b
...
@@ -238,13 +238,13 @@ function internalRemoveData( elem, name, pvt ) {
...
@@ -238,13 +238,13 @@ function internalRemoveData( elem, name, pvt ) {
jQuery
.
extend
({
jQuery
.
extend
({
cache
:
{},
cache
:
{},
// The following elements
throw uncatchable exceptions if you
// The following elements
(space-suffixed to avoid Object.prototype collisions)
//
attempt to add expando properties to them.
//
throw uncatchable exceptions if you attempt to set expando properties
noData
:
{
noData
:
{
"applet"
:
true
,
"applet
"
:
true
,
"embed"
:
true
,
"embed
"
:
true
,
//
Ban all objects except for Flash (which handle expandos)
//
...but Flash objects (which have this classid) *can* handle expandos
"object"
:
"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
"object
"
:
"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
},
},
hasData
:
function
(
elem
)
{
hasData
:
function
(
elem
)
{
...
...
src/data/accepts.js
View file @
126d596b
...
@@ -6,15 +6,15 @@ define([
...
@@ -6,15 +6,15 @@ define([
* Determines whether an object can have data
* Determines whether an object can have data
*/
*/
jQuery
.
acceptData
=
function
(
elem
)
{
jQuery
.
acceptData
=
function
(
elem
)
{
// Do not set data on non-element because it will not be cleared (#8335).
var
noData
=
jQuery
.
noData
[
(
elem
.
nodeName
+
" "
).
toLowerCase
()
],
if
(
elem
.
nodeType
&&
elem
.
nodeType
!==
1
&&
elem
.
nodeType
!==
9
)
{
nodeType
=
+
elem
.
nodeType
||
1
;
return
false
;
}
var
noData
=
elem
.
nodeName
&&
jQuery
.
noData
[
elem
.
nodeName
.
toLowerCase
()
];
// Do not set data on non-element DOM nodes because it will not be cleared (#8335).
return
nodeType
!==
1
&&
nodeType
!==
9
?
false
:
// n
odes accept data unless otherwise specified; rejection can be conditional
// N
odes accept data unless otherwise specified; rejection can be conditional
return
!
noData
||
noData
!==
true
&&
elem
.
getAttribute
(
"classid"
)
===
noData
;
!
noData
||
noData
!==
true
&&
elem
.
getAttribute
(
"classid"
)
===
noData
;
};
};
return
jQuery
.
acceptData
;
return
jQuery
.
acceptData
;
...
...
test/data/core/aliased.html
0 → 100644
View file @
126d596b
<!doctype html>
<html>
<head>
<meta
http-equiv=
"Content-type"
content=
"text/html; charset=utf-8"
/>
<title>
alias-masked DOM properties (#14074)
</title>
<script>
var
errors
=
[];
window
.
onerror
=
function
(
errorMessage
,
filePath
,
lineNumber
)
{
errors
.
push
(
errorMessage
);
};
</script>
<script
src=
"../../jquery.js"
></script>
</head>
<body>
<form>
<input
type=
"text"
id=
"nodeName"
/>
</form>
<script>
jQuery
(
function
()
{
window
.
parent
.
iframeCallback
(
errors
);
});
</script>
</body>
</html>
test/unit/core.js
View file @
126d596b
...
@@ -1419,3 +1419,10 @@ testIframeWithCallback( "Conditional compilation compatibility (#13274)", "core/
...
@@ -1419,3 +1419,10 @@ testIframeWithCallback( "Conditional compilation compatibility (#13274)", "core/
deepEqual
(
errors
,
[],
"No errors"
);
deepEqual
(
errors
,
[],
"No errors"
);
ok
(
$
(),
"jQuery executes"
);
ok
(
$
(),
"jQuery executes"
);
});
});
testIframeWithCallback
(
"Tolerating alias-masked DOM properties (#14074)"
,
"core/aliased.html"
,
function
(
errors
)
{
expect
(
1
);
deepEqual
(
errors
,
[],
"jQuery loaded"
);
}
);
test/unit/data.js
View file @
126d596b
...
@@ -142,26 +142,30 @@ test("Data is not being set on comment and text nodes", function() {
...
@@ -142,26 +142,30 @@ test("Data is not being set on comment and text nodes", function() {
});
});
test
(
"jQuery.acceptData"
,
function
()
{
test
(
"jQuery.acceptData"
,
function
()
{
expect
(
9
);
expect
(
10
);
var
flash
,
applet
;
var
flash
,
applet
;
ok
(
jQuery
.
acceptData
(
document
),
"document"
);
ok
(
jQuery
.
acceptData
(
document
),
"document"
);
ok
(
jQuery
.
acceptData
(
document
.
documentElement
),
"documentElement"
);
ok
(
jQuery
.
acceptData
(
document
.
documentElement
),
"documentElement"
);
ok
(
jQuery
.
acceptData
(
{}
),
"object"
);
ok
(
jQuery
.
acceptData
(
{}
),
"object"
);
ok
(
!
jQuery
.
acceptData
(
document
.
createElement
(
"embed"
)
),
"embed"
);
ok
(
!
jQuery
.
acceptData
(
document
.
createElement
(
"embed"
)
),
"embed"
);
ok
(
!
jQuery
.
acceptData
(
document
.
createElement
(
"applet"
)
),
"applet"
);
ok
(
!
jQuery
.
acceptData
(
document
.
createElement
(
"applet"
)
),
"applet"
);
flash
=
document
.
createElement
(
"object"
);
flash
=
document
.
createElement
(
"object"
);
flash
.
setAttribute
(
"classid"
,
"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
);
flash
.
setAttribute
(
"classid"
,
"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
);
ok
(
jQuery
.
acceptData
(
flash
),
"flash"
);
ok
(
jQuery
.
acceptData
(
flash
),
"flash"
);
applet
=
document
.
createElement
(
"object"
);
applet
=
document
.
createElement
(
"object"
);
applet
.
setAttribute
(
"classid"
,
"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
);
applet
.
setAttribute
(
"classid"
,
"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
);
ok
(
!
jQuery
.
acceptData
(
applet
),
"applet"
);
ok
(
!
jQuery
.
acceptData
(
applet
),
"applet"
);
ok
(
!
jQuery
.
acceptData
(
document
.
createComment
(
""
)
),
"comment"
);
ok
(
!
jQuery
.
acceptData
(
document
.
createComment
(
""
)
),
"comment"
);
ok
(
!
jQuery
.
acceptData
(
document
.
createTextNode
(
""
)
),
"text"
);
ok
(
!
jQuery
.
acceptData
(
document
.
createTextNode
(
""
)
),
"text"
);
ok
(
jQuery
.
acceptData
(
jQuery
(
"#form"
).
append
(
"<input id='nodeType'/><input id='nodeName'/>"
)[
0
]
),
"form with aliased DOM properties"
);
});
});
// attempting to access the data of an undefined jQuery element should be undefined
// attempting to access the data of an undefined jQuery element should be undefined
...
...
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