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
c51b2947
Commit
c51b2947
authored
Oct 22, 2011
by
timmywil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support setting both the enctype attribute and property (encoding in IE6/7). Fixes #6743.
parent
f2c1d2e0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
18 deletions
+39
-18
attributes.js
src/attributes.js
+7
-1
support.js
src/support.js
+3
-0
attributes.js
test/unit/attributes.js
+29
-17
No files found.
src/attributes.js
View file @
c51b2947
...
@@ -316,7 +316,8 @@ jQuery.extend({
...
@@ -316,7 +316,8 @@ jQuery.extend({
notxml
=
nType
!==
1
||
!
jQuery
.
isXMLDoc
(
elem
);
notxml
=
nType
!==
1
||
!
jQuery
.
isXMLDoc
(
elem
);
// Normalize the name if needed
// All attributes are lowercase
// Grab necessary hook if one is defined
if
(
notxml
)
{
if
(
notxml
)
{
name
=
name
.
toLowerCase
();
name
=
name
.
toLowerCase
();
hooks
=
jQuery
.
attrHooks
[
name
]
||
(
rboolean
.
test
(
name
)
?
boolHook
:
nodeHook
);
hooks
=
jQuery
.
attrHooks
[
name
]
||
(
rboolean
.
test
(
name
)
?
boolHook
:
nodeHook
);
...
@@ -619,6 +620,11 @@ if ( !jQuery.support.optSelected ) {
...
@@ -619,6 +620,11 @@ if ( !jQuery.support.optSelected ) {
});
});
}
}
// IE6/7 call enctype encoding
if
(
!
jQuery
.
support
.
enctype
)
{
jQuery
.
propFix
.
enctype
=
"encoding"
;
}
// Radios and checkboxes getter/setter
// Radios and checkboxes getter/setter
if
(
!
jQuery
.
support
.
checkOn
)
{
if
(
!
jQuery
.
support
.
checkOn
)
{
jQuery
.
each
([
"radio"
,
"checkbox"
],
function
()
{
jQuery
.
each
([
"radio"
,
"checkbox"
],
function
()
{
...
...
src/support.js
View file @
c51b2947
...
@@ -85,6 +85,9 @@ jQuery.support = (function() {
...
@@ -85,6 +85,9 @@ jQuery.support = (function() {
// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
getSetAttribute
:
div
.
className
!==
"t"
,
getSetAttribute
:
div
.
className
!==
"t"
,
// Tests for enctype support on a form(#6743)
enctype
:
!!
document
.
createElement
(
"form"
).
enctype
,
// Will be defined later
// Will be defined later
submitBubbles
:
true
,
submitBubbles
:
true
,
changeBubbles
:
true
,
changeBubbles
:
true
,
...
...
test/unit/attributes.js
View file @
c51b2947
...
@@ -12,25 +12,29 @@ test("jQuery.propFix integrity test", function() {
...
@@ -12,25 +12,29 @@ test("jQuery.propFix integrity test", function() {
// overwrites don't occur
// overwrites don't occur
// This is simply for better code coverage and future proofing.
// This is simply for better code coverage and future proofing.
var
props
=
{
var
props
=
{
tabindex
:
"tabIndex"
,
tabindex
:
"tabIndex"
,
readonly
:
"readOnly"
,
readonly
:
"readOnly"
,
"for"
:
"htmlFor"
,
"for"
:
"htmlFor"
,
"class"
:
"className"
,
"class"
:
"className"
,
maxlength
:
"maxLength"
,
maxlength
:
"maxLength"
,
cellspacing
:
"cellSpacing"
,
cellspacing
:
"cellSpacing"
,
cellpadding
:
"cellPadding"
,
cellpadding
:
"cellPadding"
,
rowspan
:
"rowSpan"
,
rowspan
:
"rowSpan"
,
colspan
:
"colSpan"
,
colspan
:
"colSpan"
,
usemap
:
"useMap"
,
usemap
:
"useMap"
,
frameborder
:
"frameBorder"
,
frameborder
:
"frameBorder"
,
contenteditable
:
"contentEditable"
contenteditable
:
"contentEditable"
};
};
if
(
!
jQuery
.
support
.
enctype
)
{
props
.
enctype
=
"encoding"
;
}
deepEqual
(
props
,
jQuery
.
propFix
,
"jQuery.propFix passes integrity check"
);
deepEqual
(
props
,
jQuery
.
propFix
,
"jQuery.propFix passes integrity check"
);
});
});
test
(
"attr(String)"
,
function
()
{
test
(
"attr(String)"
,
function
()
{
expect
(
4
5
);
expect
(
4
6
);
equals
(
jQuery
(
"#text1"
).
attr
(
"type"
),
"text"
,
"Check for type attribute"
);
equals
(
jQuery
(
"#text1"
).
attr
(
"type"
),
"text"
,
"Check for type attribute"
);
equals
(
jQuery
(
"#radio1"
).
attr
(
"type"
),
"radio"
,
"Check for type attribute"
);
equals
(
jQuery
(
"#radio1"
).
attr
(
"type"
),
"radio"
,
"Check for type attribute"
);
...
@@ -118,6 +122,9 @@ test("attr(String)", function() {
...
@@ -118,6 +122,9 @@ test("attr(String)", function() {
ok
(
jQuery
().
attr
(
"doesntexist"
)
===
undefined
,
"Make sure undefined is returned when no element is there."
);
ok
(
jQuery
().
attr
(
"doesntexist"
)
===
undefined
,
"Make sure undefined is returned when no element is there."
);
equal
(
jQuery
(
"<div/>"
).
attr
(
"value"
),
undefined
,
"An unset value on a div returns undefined."
);
equal
(
jQuery
(
"<div/>"
).
attr
(
"value"
),
undefined
,
"An unset value on a div returns undefined."
);
equal
(
jQuery
(
"<input/>"
).
attr
(
"value"
),
""
,
"An unset value on an input returns current value."
);
equal
(
jQuery
(
"<input/>"
).
attr
(
"value"
),
""
,
"An unset value on an input returns current value."
);
$form
=
jQuery
(
"#form"
).
attr
(
"enctype"
,
"multipart/form-data"
);
equal
(
$form
.
prop
(
"enctype"
),
"multipart/form-data"
,
"Set the enctype of a form (encoding in IE6/7 #6743)"
);
});
});
if
(
!
isLocal
)
{
if
(
!
isLocal
)
{
...
@@ -475,7 +482,7 @@ test("removeAttr(String)", function() {
...
@@ -475,7 +482,7 @@ test("removeAttr(String)", function() {
});
});
test
(
"prop(String, Object)"
,
function
()
{
test
(
"prop(String, Object)"
,
function
()
{
expect
(
3
0
);
expect
(
3
1
);
equals
(
jQuery
(
"#text1"
).
prop
(
"value"
),
"Test"
,
"Check for value attribute"
);
equals
(
jQuery
(
"#text1"
).
prop
(
"value"
),
"Test"
,
"Check for value attribute"
);
equals
(
jQuery
(
"#text1"
).
prop
(
"value"
,
"Test2"
).
prop
(
"defaultValue"
),
"Test"
,
"Check for defaultValue attribute"
);
equals
(
jQuery
(
"#text1"
).
prop
(
"value"
,
"Test2"
).
prop
(
"defaultValue"
),
"Test"
,
"Check for defaultValue attribute"
);
...
@@ -505,7 +512,9 @@ test("prop(String, Object)", function() {
...
@@ -505,7 +512,9 @@ test("prop(String, Object)", function() {
equals
(
jQuery
(
"#table"
).
prop
(
"frameBorder"
),
1
,
"Check setting and retrieving frameBorder"
);
equals
(
jQuery
(
"#table"
).
prop
(
"frameBorder"
),
1
,
"Check setting and retrieving frameBorder"
);
QUnit
.
reset
();
QUnit
.
reset
();
var
body
=
document
.
body
,
$body
=
jQuery
(
body
);
var
body
=
document
.
body
,
$body
=
jQuery
(
body
);
ok
(
$body
.
prop
(
"nextSibling"
)
===
null
,
"Make sure a null expando returns null"
);
ok
(
$body
.
prop
(
"nextSibling"
)
===
null
,
"Make sure a null expando returns null"
);
body
.
foo
=
"bar"
;
body
.
foo
=
"bar"
;
equals
(
$body
.
prop
(
"foo"
),
"bar"
,
"Make sure the expando is preferred over the dom attribute"
);
equals
(
$body
.
prop
(
"foo"
),
"bar"
,
"Make sure the expando is preferred over the dom attribute"
);
...
@@ -527,13 +536,16 @@ test("prop(String, Object)", function() {
...
@@ -527,13 +536,16 @@ test("prop(String, Object)", function() {
strictEqual
(
jQuery
(
ele
).
prop
(
"nonexisting"
),
undefined
,
"prop works correctly for non existing attributes (bug #7500)."
);
strictEqual
(
jQuery
(
ele
).
prop
(
"nonexisting"
),
undefined
,
"prop works correctly for non existing attributes (bug #7500)."
);
});
});
var
obj
=
{};
obj
=
{};
jQuery
.
each
(
[
document
,
obj
],
function
(
i
,
ele
)
{
jQuery
.
each
(
[
document
,
obj
],
function
(
i
,
ele
)
{
var
$ele
=
jQuery
(
ele
);
var
$ele
=
jQuery
(
ele
);
$ele
.
prop
(
"nonexisting"
,
"foo"
);
$ele
.
prop
(
"nonexisting"
,
"foo"
);
equal
(
$ele
.
prop
(
"nonexisting"
),
"foo"
,
"prop(name, value) works correctly for non existing attributes (bug #7500)."
);
equal
(
$ele
.
prop
(
"nonexisting"
),
"foo"
,
"prop(name, value) works correctly for non existing attributes (bug #7500)."
);
});
});
jQuery
(
document
).
removeProp
(
"nonexisting"
);
jQuery
(
document
).
removeProp
(
"nonexisting"
);
var
$form
=
jQuery
(
"#form"
).
prop
(
"enctype"
,
"multipart/form-data"
);
equal
(
$form
.
prop
(
"enctype"
),
"multipart/form-data"
,
"Set the enctype of a form (encoding in IE6/7 #6743)"
);
});
});
test
(
"removeAttr(Multi String)"
,
function
()
{
test
(
"removeAttr(Multi String)"
,
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