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
e73990a5
Commit
e73990a5
authored
Mar 17, 2009
by
Brandon Aaron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix for #3688, setting type attribute on button causes IE to throw error
parent
aabf635c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
3 deletions
+13
-3
core.js
src/core.js
+1
-1
index.html
test/index.html
+1
-1
core.js
test/unit/core.js
+11
-1
No files found.
src/core.js
View file @
e73990a5
...
@@ -1004,7 +1004,7 @@ jQuery.extend({
...
@@ -1004,7 +1004,7 @@ jQuery.extend({
if
(
name
in
elem
&&
notxml
&&
!
special
)
{
if
(
name
in
elem
&&
notxml
&&
!
special
)
{
if
(
set
){
if
(
set
){
// We can't allow the type property to be changed (since it causes problems in IE)
// We can't allow the type property to be changed (since it causes problems in IE)
if
(
name
==
"type"
&&
jQuery
.
nodeName
(
elem
,
"input"
)
&&
elem
.
parentNode
)
if
(
name
==
"type"
&&
elem
.
nodeName
.
match
(
/
(
button|input
)
/i
)
&&
elem
.
parentNode
)
throw
"type property can't be changed"
;
throw
"type property can't be changed"
;
elem
[
name
]
=
value
;
elem
[
name
]
=
value
;
...
...
test/index.html
View file @
e73990a5
...
@@ -70,7 +70,7 @@
...
@@ -70,7 +70,7 @@
<input
type=
"text"
id=
"name"
name=
"name"
value=
"name"
/>
<input
type=
"text"
id=
"name"
name=
"name"
value=
"name"
/>
<input
type=
"search"
id=
"search"
name=
"search"
value=
"search"
/>
<input
type=
"search"
id=
"search"
name=
"search"
value=
"search"
/>
<button
id=
"button"
name=
"button"
>
Button
</button>
<button
id=
"button"
name=
"button"
type=
"button"
>
Button
</button>
<textarea
id=
"area1"
maxlength=
"30"
>
foobar
</textarea>
<textarea
id=
"area1"
maxlength=
"30"
>
foobar
</textarea>
...
...
test/unit/core.js
View file @
e73990a5
...
@@ -463,7 +463,7 @@ test("attr(Hash)", function() {
...
@@ -463,7 +463,7 @@ test("attr(Hash)", function() {
});
});
test
(
"attr(String, Object)"
,
function
()
{
test
(
"attr(String, Object)"
,
function
()
{
expect
(
19
);
expect
(
21
);
var
div
=
jQuery
(
"div"
).
attr
(
"foo"
,
"bar"
),
var
div
=
jQuery
(
"div"
).
attr
(
"foo"
,
"bar"
),
fail
=
false
;
fail
=
false
;
for
(
var
i
=
0
;
i
<
div
.
size
();
i
++
)
{
for
(
var
i
=
0
;
i
<
div
.
size
();
i
++
)
{
...
@@ -537,6 +537,16 @@ test("attr(String, Object)", function() {
...
@@ -537,6 +537,16 @@ test("attr(String, Object)", function() {
}
}
ok
(
thrown
,
"Exception thrown when trying to change type property"
);
ok
(
thrown
,
"Exception thrown when trying to change type property"
);
equals
(
"checkbox"
,
check
.
attr
(
'type'
),
"Verify that you can change the type of an input element that isn't in the DOM"
);
equals
(
"checkbox"
,
check
.
attr
(
'type'
),
"Verify that you can change the type of an input element that isn't in the DOM"
);
var
button
=
jQuery
(
"#button"
);
var
thrown
=
false
;
try
{
button
.
attr
(
'type'
,
'submit'
);
}
catch
(
e
)
{
thrown
=
true
;
}
ok
(
thrown
,
"Exception thrown when trying to change type property"
);
equals
(
"button"
,
button
.
attr
(
'type'
),
"Verify that you can't change the type of a button element"
);
});
});
if
(
!
isLocal
)
{
if
(
!
isLocal
)
{
...
...
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