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
edb22865
Commit
edb22865
authored
May 25, 2011
by
timmywil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return null for outer/inner width/height calls on window/document. Fixes #7557.
parent
1d1cb582
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
9 deletions
+37
-9
css.js
src/css.js
+5
-1
dimensions.js
src/dimensions.js
+6
-4
dimensions.js
test/unit/dimensions.js
+26
-4
No files found.
src/css.js
View file @
edb22865
...
@@ -170,6 +170,11 @@ jQuery.each(["height", "width"], function( i, name ) {
...
@@ -170,6 +170,11 @@ jQuery.each(["height", "width"], function( i, name ) {
get
:
function
(
elem
,
computed
,
extra
)
{
get
:
function
(
elem
,
computed
,
extra
)
{
var
val
;
var
val
;
// Tests for window/document
if
(
!
elem
.
style
)
{
return
null
;
}
if
(
computed
)
{
if
(
computed
)
{
if
(
elem
.
offsetWidth
!==
0
)
{
if
(
elem
.
offsetWidth
!==
0
)
{
val
=
getWH
(
elem
,
name
,
extra
);
val
=
getWH
(
elem
,
name
,
extra
);
...
@@ -196,7 +201,6 @@ jQuery.each(["height", "width"], function( i, name ) {
...
@@ -196,7 +201,6 @@ jQuery.each(["height", "width"], function( i, name ) {
if
(
val
<
0
||
val
==
null
)
{
if
(
val
<
0
||
val
==
null
)
{
val
=
elem
.
style
[
name
];
val
=
elem
.
style
[
name
];
// Should return "auto" instead of 0, use 0 for
// Should return "auto" instead of 0, use 0 for
// temporary backwards-compat
// temporary backwards-compat
return
val
===
""
||
val
===
"auto"
?
"0px"
:
val
;
return
val
===
""
||
val
===
"auto"
?
"0px"
:
val
;
...
...
src/dimensions.js
View file @
edb22865
...
@@ -7,15 +7,17 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
...
@@ -7,15 +7,17 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
// innerHeight and innerWidth
// innerHeight and innerWidth
jQuery
.
fn
[
"inner"
+
name
]
=
function
()
{
jQuery
.
fn
[
"inner"
+
name
]
=
function
()
{
return
this
[
0
]
?
var
ret
;
parseFloat
(
jQuery
.
css
(
this
[
0
],
type
,
"padding"
)
)
:
return
this
[
0
]
&&
!
isNaN
(
ret
=
parseFloat
(
jQuery
.
css
(
this
[
0
],
type
,
"padding"
))
)
?
ret
:
null
;
null
;
};
};
// outerHeight and outerWidth
// outerHeight and outerWidth
jQuery
.
fn
[
"outer"
+
name
]
=
function
(
margin
)
{
jQuery
.
fn
[
"outer"
+
name
]
=
function
(
margin
)
{
return
this
[
0
]
?
var
ret
;
parseFloat
(
jQuery
.
css
(
this
[
0
],
type
,
margin
?
"margin"
:
"border"
)
)
:
return
this
[
0
]
&&
!
isNaN
(
ret
=
parseFloat
(
jQuery
.
css
(
this
[
0
],
type
,
margin
?
"margin"
:
"border"
))
)
?
ret
:
null
;
null
;
};
};
...
...
test/unit/dimensions.js
View file @
edb22865
...
@@ -107,7 +107,13 @@ test("height() with function args", function() {
...
@@ -107,7 +107,13 @@ test("height() with function args", function() {
});
});
test
(
"innerWidth()"
,
function
()
{
test
(
"innerWidth()"
,
function
()
{
expect
(
4
);
expect
(
8
);
equals
(
jQuery
(
window
).
innerWidth
(),
null
,
"Test on window without margin option"
);
equals
(
jQuery
(
window
).
innerWidth
(
true
),
null
,
"Test on window with margin option"
);
equals
(
jQuery
(
document
).
innerWidth
(),
null
,
"Test on document without margin option"
);
equals
(
jQuery
(
document
).
innerWidth
(
true
),
null
,
"Test on document with margin option"
);
var
$div
=
jQuery
(
"#nothiddendiv"
);
var
$div
=
jQuery
(
"#nothiddendiv"
);
// set styles
// set styles
...
@@ -136,7 +142,13 @@ test("innerWidth()", function() {
...
@@ -136,7 +142,13 @@ test("innerWidth()", function() {
});
});
test
(
"innerHeight()"
,
function
()
{
test
(
"innerHeight()"
,
function
()
{
expect
(
4
);
expect
(
8
);
equals
(
jQuery
(
window
).
innerHeight
(),
null
,
"Test on window without margin option"
);
equals
(
jQuery
(
window
).
innerHeight
(
true
),
null
,
"Test on window with margin option"
);
equals
(
jQuery
(
document
).
innerHeight
(),
null
,
"Test on document without margin option"
);
equals
(
jQuery
(
document
).
innerHeight
(
true
),
null
,
"Test on document with margin option"
);
var
$div
=
jQuery
(
"#nothiddendiv"
);
var
$div
=
jQuery
(
"#nothiddendiv"
);
// set styles
// set styles
...
@@ -165,7 +177,12 @@ test("innerHeight()", function() {
...
@@ -165,7 +177,12 @@ test("innerHeight()", function() {
});
});
test
(
"outerWidth()"
,
function
()
{
test
(
"outerWidth()"
,
function
()
{
expect
(
7
);
expect
(
11
);
equal
(
jQuery
(
window
).
outerWidth
(),
null
,
"Test on window without margin option"
);
equal
(
jQuery
(
window
).
outerWidth
(
true
),
null
,
"Test on window with margin option"
);
equal
(
jQuery
(
document
).
outerWidth
(),
null
,
"Test on document without margin option"
);
equal
(
jQuery
(
document
).
outerWidth
(
true
),
null
,
"Test on document with margin option"
);
var
$div
=
jQuery
(
"#nothiddendiv"
);
var
$div
=
jQuery
(
"#nothiddendiv"
);
$div
.
css
(
"width"
,
30
);
$div
.
css
(
"width"
,
30
);
...
@@ -195,7 +212,12 @@ test("outerWidth()", function() {
...
@@ -195,7 +212,12 @@ test("outerWidth()", function() {
});
});
test
(
"outerHeight()"
,
function
()
{
test
(
"outerHeight()"
,
function
()
{
expect
(
7
);
expect
(
11
);
equal
(
jQuery
(
window
).
outerHeight
(),
null
,
"Test on window without margin option"
);
equal
(
jQuery
(
window
).
outerHeight
(
true
),
null
,
"Test on window with margin option"
);
equal
(
jQuery
(
document
).
outerHeight
(),
null
,
"Test on document without margin option"
);
equal
(
jQuery
(
document
).
outerHeight
(
true
),
null
,
"Test on document with margin option"
);
var
$div
=
jQuery
(
"#nothiddendiv"
);
var
$div
=
jQuery
(
"#nothiddendiv"
);
$div
.
css
(
"height"
,
30
);
$div
.
css
(
"height"
,
30
);
...
...
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