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
ef7bce7e
Commit
ef7bce7e
authored
Oct 16, 2012
by
Daniel Galvez
Committed by
Dave Methvin
Oct 16, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #11280. IE6-8 need name attribute to parse param. Close gh-914.
parent
fcaef889
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
3 deletions
+54
-3
AUTHORS.txt
AUTHORS.txt
+2
-1
manipulation.js
src/manipulation.js
+20
-2
manipulation.js
test/unit/manipulation.js
+32
-0
No files found.
AUTHORS.txt
View file @
ef7bce7e
...
...
@@ -132,4 +132,5 @@ Elijah Manor <elijah.manor@gmail.com>
Daniel Chatfield <chatfielddaniel@gmail.com>
Nikita Govorov <nikita.govorov@gmail.com>
Michael Pennisi <mike@mikepennisi.com>
Markus Staab <markus.staab@redaxo.de>
\ No newline at end of file
Markus Staab <markus.staab@redaxo.de>
Daniel Gálvez <dgalvez@editablething.com>
\ No newline at end of file
src/manipulation.js
View file @
ef7bce7e
...
...
@@ -39,7 +39,8 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
_default
:
[
0
,
""
,
""
]
},
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
.
tbody
=
wrapMap
.
tfoot
=
wrapMap
.
colgroup
=
wrapMap
.
caption
=
wrapMap
.
thead
;
...
...
@@ -49,6 +50,23 @@ wrapMap.th = wrapMap.td;
// unless wrapped in a div with non-breaking characters in front of it.
if
(
!
jQuery
.
support
.
htmlSerialize
)
{
wrapMap
.
_default
=
[
1
,
"X<div>"
,
"</div>"
];
// Fixes #11280
wrapMap
.
param
=
[
1
,
"X<object>"
,
"</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
({
...
...
@@ -674,7 +692,7 @@ jQuery.extend({
tag
=
(
rtagName
.
exec
(
elem
)
||
[
""
,
""
]
)[
1
].
toLowerCase
();
wrap
=
wrapMap
[
tag
]
||
wrapMap
.
_default
;
depth
=
wrap
[
0
];
div
.
innerHTML
=
wrap
[
1
]
+
elem
+
wrap
[
2
];
div
.
innerHTML
=
wrap
[
1
]
+
addMandatoryAttributes
(
elem
)
+
wrap
[
2
];
// Move to the right depth
while
(
depth
--
)
{
...
...
test/unit/manipulation.js
View file @
ef7bce7e
...
...
@@ -469,6 +469,38 @@ test("append(Function)", function() {
testAppend
(
manipulationFunctionReturningObj
);
});
test
(
"append(param) to object, see #11280"
,
function
()
{
expect
(
11
);
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
);
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
(
$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
);
equal
(
$objectElement
.
children
().
length
,
1
,
"param single insertion ok"
);
equal
(
jQuery
(
objectElement
.
childNodes
[
0
]).
attr
(
"name"
),
"foo"
,
"param.eq(0) has name=foo"
);
equal
(
newObject
.
children
().
length
,
3
,
"param wrapper multiple insertion ok"
);
equal
(
newObject
.
children
().
eq
(
0
).
attr
(
"type"
),
"foo"
,
"param.eq(0) has type=foo"
);
equal
(
newObject
.
children
().
eq
(
1
).
attr
(
"value"
),
"foo2"
,
"param.eq(1) has value=foo2"
);
equal
(
newObject
.
children
().
eq
(
2
).
attr
(
"name"
),
"bar"
,
"param.eq(2) has name=bar"
);
});
test
(
"append(Function) with incoming value"
,
function
()
{
expect
(
12
);
...
...
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