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
bb570fc3
Commit
bb570fc3
authored
Nov 21, 2012
by
Richard Gibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #12920: remove addMandatoryAttributes. Close gh-1037.
parent
22f58bd6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
54 deletions
+18
-54
manipulation.js
src/manipulation.js
+9
-29
manipulation.js
test/unit/manipulation.js
+9
-25
No files found.
src/manipulation.js
View file @
bb570fc3
...
@@ -32,44 +32,24 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
...
@@ -32,44 +32,24 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
wrapMap
=
{
wrapMap
=
{
option
:
[
1
,
"<select multiple='multiple'>"
,
"</select>"
],
option
:
[
1
,
"<select multiple='multiple'>"
,
"</select>"
],
legend
:
[
1
,
"<fieldset>"
,
"</fieldset>"
],
legend
:
[
1
,
"<fieldset>"
,
"</fieldset>"
],
area
:
[
1
,
"<map>"
,
"</map>"
],
param
:
[
1
,
"<object>"
,
"</object>"
],
thead
:
[
1
,
"<table>"
,
"</table>"
],
thead
:
[
1
,
"<table>"
,
"</table>"
],
tr
:
[
2
,
"<table><tbody>"
,
"</tbody></table>"
],
tr
:
[
2
,
"<table><tbody>"
,
"</tbody></table>"
],
td
:
[
3
,
"<table><tbody><tr>"
,
"</tr></tbody></table>"
],
col
:
[
2
,
"<table><tbody></tbody><colgroup>"
,
"</colgroup></table>"
],
col
:
[
2
,
"<table><tbody></tbody><colgroup>"
,
"</colgroup></table>"
],
area
:
[
1
,
"<map>"
,
"</map>"
],
td
:
[
3
,
"<table><tbody><tr>"
,
"</tr></tbody></table>"
],
_default
:
[
0
,
""
,
""
]
// 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.
_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"
)
);
addMandatoryAttributes
=
function
(
elem
)
{
return
elem
;
};
wrapMap
.
optgroup
=
wrapMap
.
option
;
wrapMap
.
optgroup
=
wrapMap
.
option
;
wrapMap
.
tbody
=
wrapMap
.
tfoot
=
wrapMap
.
colgroup
=
wrapMap
.
caption
=
wrapMap
.
thead
;
wrapMap
.
tbody
=
wrapMap
.
tfoot
=
wrapMap
.
colgroup
=
wrapMap
.
caption
=
wrapMap
.
thead
;
wrapMap
.
th
=
wrapMap
.
td
;
wrapMap
.
th
=
wrapMap
.
td
;
// 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.
if
(
!
jQuery
.
support
.
htmlSerialize
)
{
wrapMap
.
_default
=
[
1
,
"X<div>"
,
""
];
// Fixes #11280
wrapMap
.
param
=
[
1
,
"X<object>"
,
""
];
// Fixes #11280. HTMLParam name attribute added to avoid IE6-8 parsing issue.
addMandatoryAttributes
=
function
(
elem
)
{
// If it's a param
return
elem
.
replace
(
/<param
([^
>
]
*
)
>/gi
,
function
(
m
,
s1
,
offset
)
{
var
name
=
s1
.
match
(
/name=
[
"'
]([^
"'
]
*
)[
"'
]
/i
);
return
name
?
(
name
[
1
].
length
?
// It has a name attr with a value
"<param"
+
s1
+
">"
:
// It has name attr without a value
"<param"
+
s1
.
replace
(
name
[
0
],
"name='_"
+
offset
+
"'"
)
+
">"
)
:
// No name attr
"<param name='_"
+
offset
+
"' "
+
s1
+
">"
;
});
};
}
jQuery
.
fn
.
extend
({
jQuery
.
fn
.
extend
({
text
:
function
(
value
)
{
text
:
function
(
value
)
{
return
jQuery
.
access
(
this
,
function
(
value
)
{
return
jQuery
.
access
(
this
,
function
(
value
)
{
...
@@ -733,7 +713,7 @@ jQuery.extend({
...
@@ -733,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
]
+
addMandatoryAttributes
(
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/manipulation.js
View file @
bb570fc3
...
@@ -451,35 +451,19 @@ test("append(Function)", function() {
...
@@ -451,35 +451,19 @@ test("append(Function)", function() {
});
});
test
(
"append(param) to object, see #11280"
,
function
()
{
test
(
"append(param) to object, see #11280"
,
function
()
{
expect
(
11
);
expect
(
5
);
var
objectElement
=
document
.
createElement
(
"object"
),
$objectElement
=
jQuery
(
objectElement
),
paramElement
=
jQuery
(
"<param type='wmode' value='transparent'/>"
),
paramElement2
=
jQuery
(
"<param name='' type='wmode2' value='transparent2' />"
),
paramElement3
=
jQuery
(
"<param type='wmode' name='foo' >"
),
newObject
=
jQuery
(
"<object><param type='foo' ><param name='' value='foo2'/><param type='baz' name='bar'></object>"
);
equal
(
objectElement
.
childNodes
.
length
,
0
,
"object did not have childNodes previously"
);
document
.
body
.
appendChild
(
objectElement
);
$objectElement
.
append
(
paramElement
);
var
object
=
jQuery
(
document
.
createElement
(
"object"
)
).
appendTo
(
document
.
body
);
equal
(
$objectElement
.
children
().
length
,
1
,
"param single insertion ok"
);
equal
(
jQuery
(
objectElement
.
childNodes
[
0
]).
attr
(
"type"
),
"wmode"
,
"param.eq(0) has type=wmode"
);
$objectElement
.
html
(
paramElement2
);
equal
(
object
.
children
().
length
,
0
,
"object does not start with children"
);
equal
(
$objectElement
.
children
().
length
,
1
,
"param single insertion ok"
);
equal
(
jQuery
(
objectElement
.
childNodes
[
0
]).
attr
(
"type"
),
"wmode2"
,
"param.eq(0) has type=wmode2"
);
$objectElement
.
html
(
paramElement3
);
object
.
append
(
jQuery
(
"<param type='wmode' name='foo'>"
)
);
equal
(
$objectElement
.
children
().
length
,
1
,
"param single insertion ok
"
);
equal
(
object
.
children
().
length
,
1
,
"appended param
"
);
equal
(
jQuery
(
objectElement
.
childNodes
[
0
]).
attr
(
"name"
),
"foo"
,
"param.eq(0)
has name=foo"
);
equal
(
object
.
children
().
eq
(
0
).
attr
(
"name"
),
"foo"
,
"param
has name=foo"
);
equal
(
newObject
.
children
().
length
,
3
,
"param wrapper multiple insertion ok"
);
object
=
jQuery
(
"<object><param type='baz' name='bar'></object>"
);
equal
(
newObject
.
children
().
eq
(
0
).
attr
(
"type"
),
"foo"
,
"param.eq(0) has type=foo"
);
equal
(
object
.
children
().
length
,
1
,
"object created with child param"
);
equal
(
newObject
.
children
().
eq
(
1
).
attr
(
"value"
),
"foo2"
,
"param.eq(1) has value=foo2"
);
equal
(
object
.
children
().
eq
(
0
).
attr
(
"name"
),
"bar"
,
"param has name=bar"
);
equal
(
newObject
.
children
().
eq
(
2
).
attr
(
"name"
),
"bar"
,
"param.eq(2) has name=bar"
);
});
});
test
(
"append(Function) with incoming value"
,
function
()
{
test
(
"append(Function) with incoming value"
,
function
()
{
...
...
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