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
9ae6b1a0
Commit
9ae6b1a0
authored
Nov 28, 2012
by
Oleg
Committed by
Dave Methvin
Nov 28, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #12957. Simplify wrapMap, it doesn't need end tags. Close gh-1044.
parent
1052f9cb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
19 deletions
+18
-19
manipulation.js
src/manipulation.js
+10
-10
attributes.js
test/unit/attributes.js
+2
-5
manipulation.js
test/unit/manipulation.js
+6
-4
No files found.
src/manipulation.js
View file @
9ae6b1a0
...
@@ -30,18 +30,18 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
...
@@ -30,18 +30,18 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
rscriptTypeMasked
=
/^true
\/(
.*
)
/
,
rscriptTypeMasked
=
/^true
\/(
.*
)
/
,
rcleanScript
=
/^
\s
*<!
(?:\[
CDATA
\[
|--
)
|
(?:\]\]
|--
)
>
\s
*$/g
,
rcleanScript
=
/^
\s
*<!
(?:\[
CDATA
\[
|--
)
|
(?:\]\]
|--
)
>
\s
*$/g
,
wrapMap
=
{
wrapMap
=
{
option
:
[
1
,
"<select multiple='multiple'>"
,
"</select>"
],
option
:
[
1
,
"<select multiple='multiple'>"
],
legend
:
[
1
,
"<fieldset>"
,
"</fieldset>"
],
legend
:
[
1
,
"<fieldset>"
],
area
:
[
1
,
"<map>"
,
"</map>"
],
area
:
[
1
,
"<map>"
],
param
:
[
1
,
"<object>"
,
"</object>"
],
param
:
[
1
,
"<object>"
],
thead
:
[
1
,
"<table>"
,
"</table>"
],
thead
:
[
1
,
"<table>"
],
tr
:
[
2
,
"<table><tbody>"
,
"</tbody></table>"
],
tr
:
[
2
,
"<table><tbody>"
],
col
:
[
2
,
"<table><tbody></tbody><colgroup>"
,
"</
colgroup></
table>"
],
col
:
[
2
,
"<table><tbody></tbody><colgroup>"
,
"</table>"
],
td
:
[
3
,
"<table><tbody><tr>"
,
"</tr></tbody></table>"
],
td
:
[
3
,
"<table><tbody><tr>"
],
// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
// unless wrapped in a div with non-breaking characters in front of it.
// unless wrapped in a div with non-breaking characters in front of it.
_default
:
jQuery
.
support
.
htmlSerialize
?
[
0
,
""
,
""
]
:
[
1
,
"X<div>"
,
""
]
_default
:
jQuery
.
support
.
htmlSerialize
?
[
0
,
""
]
:
[
1
,
"X<div>"
]
},
},
safeFragment
=
createSafeFragment
(
document
),
safeFragment
=
createSafeFragment
(
document
),
fragmentDiv
=
safeFragment
.
appendChild
(
document
.
createElement
(
"div"
)
);
fragmentDiv
=
safeFragment
.
appendChild
(
document
.
createElement
(
"div"
)
);
...
@@ -713,7 +713,7 @@ jQuery.extend({
...
@@ -713,7 +713,7 @@ jQuery.extend({
// Deserialize a standard representation
// Deserialize a standard representation
tag
=
(
rtagName
.
exec
(
elem
)
||
[
""
,
""
]
)[
1
].
toLowerCase
();
tag
=
(
rtagName
.
exec
(
elem
)
||
[
""
,
""
]
)[
1
].
toLowerCase
();
wrap
=
wrapMap
[
tag
]
||
wrapMap
.
_default
;
wrap
=
wrapMap
[
tag
]
||
wrapMap
.
_default
;
tmp
.
innerHTML
=
wrap
[
1
]
+
elem
.
replace
(
rxhtmlTag
,
"<$1></$2>"
)
+
wrap
[
2
]
;
tmp
.
innerHTML
=
wrap
[
1
]
+
elem
.
replace
(
rxhtmlTag
,
"<$1></$2>"
)
+
(
wrap
[
2
]
||
""
)
;
// Descend through wrappers to the right content
// Descend through wrappers to the right content
j
=
wrap
[
0
];
j
=
wrap
[
0
];
...
...
test/unit/attributes.js
View file @
9ae6b1a0
...
@@ -94,7 +94,7 @@ test( "attr(String)", function() {
...
@@ -94,7 +94,7 @@ test( "attr(String)", function() {
equal
(
jQuery
(
"#tAnchor5"
).
attr
(
"href"
),
"#5"
,
"Check for non-absolute href (an anchor)"
);
equal
(
jQuery
(
"#tAnchor5"
).
attr
(
"href"
),
"#5"
,
"Check for non-absolute href (an anchor)"
);
jQuery
(
"<a id='tAnchor6' href='#5' />"
).
appendTo
(
"#qunit-fixture"
);
jQuery
(
"<a id='tAnchor6' href='#5' />"
).
appendTo
(
"#qunit-fixture"
);
equal
(
jQuery
(
"#tAnchor5"
).
prop
(
"href"
),
jQuery
(
"#tAnchor6"
).
prop
(
"href"
),
"Check for absolute href prop on an anchor"
);
equal
(
jQuery
(
"#tAnchor5"
).
prop
(
"href"
),
jQuery
(
"#tAnchor6"
).
prop
(
"href"
),
"Check for absolute href prop on an anchor"
);
$
(
"<script type='jquery/test' src='#5' id='scriptSrc'></script>"
).
appendTo
(
"#qunit-fixture"
);
$
(
"<script type='jquery/test' src='#5' id='scriptSrc'></script>"
).
appendTo
(
"#qunit-fixture"
);
equal
(
jQuery
(
"#tAnchor5"
).
prop
(
"href"
),
jQuery
(
"#scriptSrc"
).
prop
(
"src"
),
"Check for absolute src prop on a script"
);
equal
(
jQuery
(
"#tAnchor5"
).
prop
(
"href"
),
jQuery
(
"#scriptSrc"
).
prop
(
"src"
),
"Check for absolute src prop on a script"
);
...
@@ -1298,14 +1298,11 @@ test( "contents().hasClass() returns correct values", function() {
...
@@ -1298,14 +1298,11 @@ test( "contents().hasClass() returns correct values", function() {
});
});
test
(
"coords returns correct values in IE6/IE7, see #10828"
,
function
()
{
test
(
"coords returns correct values in IE6/IE7, see #10828"
,
function
()
{
expect
(
2
);
expect
(
1
);
var
area
,
var
area
,
map
=
jQuery
(
"<map />"
);
map
=
jQuery
(
"<map />"
);
area
=
map
.
html
(
"<area shape='rect' coords='0,0,0,0' href='#' alt='a' />"
).
find
(
"area"
);
area
=
map
.
html
(
"<area shape='rect' coords='0,0,0,0' href='#' alt='a' />"
).
find
(
"area"
);
equal
(
area
.
attr
(
"coords"
),
"0,0,0,0"
,
"did not retrieve coords correctly"
);
equal
(
area
.
attr
(
"coords"
),
"0,0,0,0"
,
"did not retrieve coords correctly"
);
area
=
map
.
html
(
"<area shape='rect' href='#' alt='a' /></map>"
).
find
(
"area"
);
equal
(
area
.
attr
(
"coords"
),
undefined
,
"did not retrieve coords correctly"
);
});
});
test/unit/manipulation.js
View file @
9ae6b1a0
...
@@ -356,7 +356,7 @@ var testAppendForObject = function(valueObj, isFragment) {
...
@@ -356,7 +356,7 @@ var testAppendForObject = function(valueObj, isFragment) {
};
};
var
testAppend
=
function
(
valueObj
)
{
var
testAppend
=
function
(
valueObj
)
{
expect
(
5
8
);
expect
(
5
9
);
testAppendForObject
(
valueObj
,
false
);
testAppendForObject
(
valueObj
,
false
);
testAppendForObject
(
valueObj
,
true
);
testAppendForObject
(
valueObj
,
true
);
...
@@ -440,6 +440,8 @@ var testAppend = function(valueObj) {
...
@@ -440,6 +440,8 @@ var testAppend = function(valueObj) {
$radioParent
.
wrap
(
"<div></div>"
);
$radioParent
.
wrap
(
"<div></div>"
);
equal
(
$radioChecked
[
0
].
checked
,
true
,
"Reappending radios uphold which radio is checked"
);
equal
(
$radioChecked
[
0
].
checked
,
true
,
"Reappending radios uphold which radio is checked"
);
equal
(
$radioUnchecked
[
0
].
checked
,
false
,
"Reappending radios uphold not being checked"
);
equal
(
$radioUnchecked
[
0
].
checked
,
false
,
"Reappending radios uphold not being checked"
);
equal
(
jQuery
(
"<div/>"
).
append
(
"option<area/>"
)[
0
].
childNodes
.
length
,
2
,
"HTML-string with leading text should be processed correctly"
);
};
};
test
(
"append(String|Element|Array<Element>|jQuery)"
,
function
()
{
test
(
"append(String|Element|Array<Element>|jQuery)"
,
function
()
{
...
@@ -537,11 +539,11 @@ test("replaceWith on XML document (#9960)", function () {
...
@@ -537,11 +539,11 @@ test("replaceWith on XML document (#9960)", function () {
xml2
=
jQuery
(
xmlDoc2
),
xml2
=
jQuery
(
xmlDoc2
),
scxml1
=
jQuery
(
":first"
,
xml1
),
scxml1
=
jQuery
(
":first"
,
xml1
),
scxml2
=
jQuery
(
":first"
,
xml2
);
scxml2
=
jQuery
(
":first"
,
xml2
);
scxml1
.
replaceWith
(
scxml2
);
scxml1
.
replaceWith
(
scxml2
);
newNode
=
jQuery
(
":first>state[id='provisioning3']"
,
xml1
);
newNode
=
jQuery
(
":first>state[id='provisioning3']"
,
xml1
);
equal
(
newNode
.
length
,
1
,
"ReplaceWith not working on document nodes."
);
equal
(
newNode
.
length
,
1
,
"ReplaceWith not working on document nodes."
);
});
});
...
...
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