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
b0a352bf
Commit
b0a352bf
authored
Sep 13, 2012
by
Dave Methvin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #12534. Don't die on browsers lacking getBoundingClientRect.
parent
74cdd784
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
offset.js
src/offset.js
+2
-2
offset.js
test/unit/offset.js
+9
-0
No files found.
src/offset.js
View file @
b0a352bf
...
...
@@ -23,8 +23,8 @@ jQuery.fn.offset = function( options ) {
docElem
=
doc
.
documentElement
;
// Make sure we
're not dealing with
a disconnected DOM node
if
(
!
jQuery
.
contains
(
docElem
,
elem
)
)
{
// Make sure we
have the API and we're it's not
a disconnected DOM node
if
(
typeof
elem
.
getBoundingClientRect
===
"undefined"
||
!
jQuery
.
contains
(
docElem
,
elem
)
)
{
return
{
top
:
0
,
left
:
0
};
}
...
...
test/unit/offset.js
View file @
b0a352bf
...
...
@@ -15,6 +15,15 @@ test("empty set", function() {
strictEqual
(
jQuery
().
position
(),
undefined
,
"position() returns undefined for empty set (#11962)"
);
});
test
(
"object without getBoundingClientRect"
,
function
()
{
expect
(
2
);
// Simulates a browser without gBCR on elements, we just want to return 0,0
var
result
=
jQuery
({
ownerDocument
:
document
}).
offset
();
equal
(
result
.
top
,
0
,
"Check top"
);
equal
(
result
.
left
,
0
,
"Check left"
);
});
test
(
"disconnected node"
,
function
()
{
expect
(
2
);
...
...
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