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
08e57b1d
Commit
08e57b1d
authored
Apr 09, 2013
by
Oleg Gaidarenko
Committed by
Timmy Willison
Apr 09, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust the return value of the tabIndex propHook to match the spec. Fixes #13752.
parent
90eb24e5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
17 deletions
+22
-17
attributes.js
src/attributes.js
+7
-13
index.html
test/index.html
+6
-0
attributes.js
test/unit/attributes.js
+9
-4
No files found.
src/attributes.js
View file @
08e57b1d
...
...
@@ -414,20 +414,14 @@ jQuery.extend({
}
if
(
value
!==
undefined
)
{
if
(
hooks
&&
"set"
in
hooks
&&
(
ret
=
hooks
.
set
(
elem
,
value
,
name
))
!==
undefined
)
{
return
ret
;
}
else
{
return
(
elem
[
name
]
=
value
);
}
return
hooks
&&
"set"
in
hooks
&&
(
ret
=
hooks
.
set
(
elem
,
value
,
name
))
!==
undefined
?
ret
:
(
elem
[
name
]
=
value
);
}
else
{
if
(
hooks
&&
"get"
in
hooks
&&
(
ret
=
hooks
.
get
(
elem
,
name
))
!==
null
)
{
return
ret
;
}
else
{
return
elem
[
name
];
}
return
hooks
&&
"get"
in
hooks
&&
(
ret
=
hooks
.
get
(
elem
,
name
))
!==
null
?
ret
:
elem
[
name
];
}
},
...
...
@@ -442,7 +436,7 @@ jQuery.extend({
parseInt
(
attributeNode
.
value
,
10
)
:
rfocusable
.
test
(
elem
.
nodeName
)
||
rclickable
.
test
(
elem
.
nodeName
)
&&
elem
.
href
?
0
:
undefined
;
-
1
;
}
}
}
...
...
test/index.html
View file @
08e57b1d
...
...
@@ -272,6 +272,12 @@ Z</textarea>
<span>
...
</span><a
id=
"linkWithNoHrefWithNoTabIndex"
>
Eat a burger
</a><span>
...
</span>
<span>
...
</span><a
id=
"linkWithNoHrefWithTabIndex"
tabindex=
"1"
>
Eat some funyuns
</a><span>
...
</span>
<span>
...
</span><a
id=
"linkWithNoHrefWithNegativeTabIndex"
tabindex=
"-1"
>
Eat some funyuns
</a><span>
...
</span>
<input
id=
"inputWithoutTabIndex"
/>
<button
id=
"buttonWithoutTabIndex"
></button>
<textarea
id=
"textareaWithoutTabIndex"
></textarea>
<menu
type=
"popup"
>
<menuitem
id=
"menuitemWithoutTabIndex"
command=
"submitbutton"
default
/>
</menu>
</div>
<div
id=
"liveHandlerOrder"
>
...
...
test/unit/attributes.js
View file @
08e57b1d
...
...
@@ -687,11 +687,16 @@ test( "prop(String, Object)", function() {
});
test
(
"prop('tabindex')"
,
function
()
{
expect
(
8
);
expect
(
11
);
// inputs without tabIndex attribute
equal
(
jQuery
(
"#inputWithoutTabIndex"
).
prop
(
"tabindex"
),
0
,
"input without tabindex"
);
equal
(
jQuery
(
"#buttonWithoutTabIndex"
).
prop
(
"tabindex"
),
0
,
"button without tabindex"
);
equal
(
jQuery
(
"#textareaWithoutTabIndex"
).
prop
(
"tabindex"
),
0
,
"textarea without tabindex"
);
// elements not natively tabbable
equal
(
jQuery
(
"#listWithTabIndex"
).
prop
(
"tabindex"
),
5
,
"not natively tabbable, with tabindex set to 0"
);
equal
(
jQuery
(
"#divWithNoTabIndex"
).
prop
(
"tabindex"
),
undefined
,
"not natively tabbable, no tabindex set"
);
equal
(
jQuery
(
"#divWithNoTabIndex"
).
prop
(
"tabindex"
),
-
1
,
"not natively tabbable, no tabindex set"
);
// anchor with href
equal
(
jQuery
(
"#linkWithNoTabIndex"
).
prop
(
"tabindex"
),
0
,
"anchor with href, no tabindex set"
);
...
...
@@ -699,7 +704,7 @@ test( "prop('tabindex')", function() {
equal
(
jQuery
(
"#linkWithNegativeTabIndex"
).
prop
(
"tabindex"
),
-
1
,
"anchor with href, tabindex set to -1"
);
// anchor without href
equal
(
jQuery
(
"#linkWithNoHrefWithNoTabIndex"
).
prop
(
"tabindex"
),
undefined
,
"anchor without href, no tabindex set"
);
equal
(
jQuery
(
"#linkWithNoHrefWithNoTabIndex"
).
prop
(
"tabindex"
),
-
1
,
"anchor without href, no tabindex set"
);
equal
(
jQuery
(
"#linkWithNoHrefWithTabIndex"
).
prop
(
"tabindex"
),
1
,
"anchor without href, tabindex set to 2"
);
equal
(
jQuery
(
"#linkWithNoHrefWithNegativeTabIndex"
).
prop
(
"tabindex"
),
-
1
,
"anchor without href, no tabindex set"
);
});
...
...
@@ -709,7 +714,7 @@ test( "prop('tabindex', value)", 10, function() {
var
clone
,
element
=
jQuery
(
"#divWithNoTabIndex"
);
equal
(
element
.
prop
(
"tabindex"
),
undefined
,
"start with no tabindex"
);
equal
(
element
.
prop
(
"tabindex"
),
-
1
,
"start with no tabindex"
);
// set a positive string
element
.
prop
(
"tabindex"
,
"1"
);
...
...
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