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
a2386a82
Commit
a2386a82
authored
May 05, 2015
by
Timmy Willison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Offset: remove ownerDocument check in offset getter
Fixes gh-2115
parent
d4dd548a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
14 deletions
+6
-14
offset.js
src/offset.js
+5
-4
offset.js
test/unit/offset.js
+1
-10
No files found.
src/offset.js
View file @
a2386a82
...
@@ -79,6 +79,7 @@ jQuery.offset = {
...
@@ -79,6 +79,7 @@ jQuery.offset = {
jQuery
.
fn
.
extend
({
jQuery
.
fn
.
extend
({
offset
:
function
(
options
)
{
offset
:
function
(
options
)
{
// Preserve chaining for setter
if
(
arguments
.
length
)
{
if
(
arguments
.
length
)
{
return
options
===
undefined
?
return
options
===
undefined
?
this
:
this
:
...
@@ -87,11 +88,10 @@ jQuery.fn.extend({
...
@@ -87,11 +88,10 @@ jQuery.fn.extend({
});
});
}
}
var
docElem
,
win
,
rect
,
var
docElem
,
win
,
rect
,
doc
,
elem
=
this
[
0
],
elem
=
this
[
0
];
doc
=
elem
&&
elem
.
ownerDocument
;
if
(
!
doc
)
{
if
(
!
elem
)
{
return
;
return
;
}
}
...
@@ -99,6 +99,7 @@ jQuery.fn.extend({
...
@@ -99,6 +99,7 @@ jQuery.fn.extend({
// Make sure element is not hidden (display: none) or disconnected
// Make sure element is not hidden (display: none) or disconnected
if
(
rect
.
width
||
rect
.
height
||
elem
.
getClientRects
().
length
)
{
if
(
rect
.
width
||
rect
.
height
||
elem
.
getClientRects
().
length
)
{
doc
=
elem
.
ownerDocument
;
win
=
getWindow
(
doc
);
win
=
getWindow
(
doc
);
docElem
=
doc
.
documentElement
;
docElem
=
doc
.
documentElement
;
...
...
test/unit/offset.js
View file @
a2386a82
...
@@ -43,20 +43,11 @@ module("offset", { setup: function(){
...
@@ -43,20 +43,11 @@ module("offset", { setup: function(){
*/
*/
test
(
"empty set"
,
function
()
{
test
(
"empty set"
,
function
()
{
expect
(
2
);
expect
(
2
);
strictEqual
(
jQuery
().
offset
(),
undefined
,
"offset() returns undefined for empty set (#11962)"
);
strictEqual
(
jQuery
().
offset
(),
undefined
,
"offset() returns undefined for empty set (#11962)"
);
strictEqual
(
jQuery
().
position
(),
undefined
,
"position() returns undefined for empty set (#11962)"
);
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 element"
,
function
()
{
test
(
"disconnected element"
,
function
()
{
expect
(
1
);
expect
(
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