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
2b0e7204
Commit
2b0e7204
authored
Oct 15, 2012
by
Sai Wong
Committed by
Dave Methvin
Oct 20, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #12048. Set attributes for XML fragments. Close gh-965.
parent
144b8bfe
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
1 deletion
+28
-1
attributes.js
src/attributes.js
+1
-1
.jshintrc
test/.jshintrc
+1
-0
testinit.js
test/data/testinit.js
+15
-0
attributes.js
test/unit/attributes.js
+11
-0
No files found.
src/attributes.js
View file @
2b0e7204
...
...
@@ -523,7 +523,7 @@ if ( !getSetAttribute ) {
// Set the existing or create a new attribute node
var
ret
=
elem
.
getAttributeNode
(
name
);
if
(
!
ret
)
{
ret
=
d
ocument
.
createAttribute
(
name
);
ret
=
elem
.
ownerD
ocument
.
createAttribute
(
name
);
elem
.
setAttributeNode
(
ret
);
}
return
(
ret
.
value
=
value
+
""
);
...
...
test/.jshintrc
View file @
2b0e7204
...
...
@@ -41,6 +41,7 @@
"testIframe": true,
"testIframeWithCallback": true,
"createDashboardXML": true,
"createXMLFragment": true,
"moduleTeardown": true,
"testFoo": true,
"foobar": true,
...
...
test/data/testinit.js
View file @
2b0e7204
...
...
@@ -102,6 +102,21 @@ var createWithFriesXML = function() {
return
jQuery
.
parseXML
(
string
);
};
var
createXMLFragment
=
function
()
{
var
xml
,
frag
;
if
(
window
.
ActiveXObject
)
{
xml
=
new
ActiveXObject
(
"msxml2.domdocument"
);
}
else
{
xml
=
document
.
implementation
.
createDocument
(
""
,
""
,
null
);
}
if
(
xml
)
{
frag
=
xml
.
createElement
(
"data"
);
}
return
frag
;
};
var
fireNative
;
if
(
document
.
createEvent
)
{
fireNative
=
function
(
node
,
type
)
{
...
...
test/unit/attributes.js
View file @
2b0e7204
...
...
@@ -522,6 +522,17 @@ test( "attr(String, Object) - Loaded via XML document", function() {
equal
(
titles
[
1
],
"Users"
,
"attr() in XML context: Check second title"
);
});
test
(
"attr(String, Object) - Loaded via XML fragment"
,
function
()
{
expect
(
2
);
var
frag
=
createXMLFragment
(),
$frag
=
jQuery
(
frag
);
$frag
.
attr
(
"test"
,
"some value"
);
equal
(
$frag
.
attr
(
"test"
),
"some value"
,
"set attribute"
);
$frag
.
attr
(
"test"
,
null
);
equal
(
$frag
.
attr
(
"test"
),
undefined
,
"remove attribute"
);
});
test
(
"attr('tabindex')"
,
function
()
{
expect
(
8
);
...
...
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