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
7e02cee5
Commit
7e02cee5
authored
Oct 22, 2010
by
jeresig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure that the correct height/width of the elements is retreived. Fixes #7225.
parent
d9a3e008
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
11 deletions
+21
-11
css.js
src/css.js
+14
-2
css.js
test/unit/css.js
+7
-9
No files found.
src/css.js
View file @
7e02cee5
...
@@ -169,11 +169,23 @@ jQuery.each(["height", "width"], function( i, name ) {
...
@@ -169,11 +169,23 @@ jQuery.each(["height", "width"], function( i, name ) {
});
});
}
}
if
(
val
<
0
||
val
===
0
&&
!
jQuery
.
contains
(
elem
.
ownerDocument
.
documentElement
,
elem
)
)
{
if
(
val
<
0
)
{
return
elem
.
style
[
name
]
||
"0px"
;
return
elem
.
style
[
name
]
||
"0px"
;
}
}
return
val
+
"px"
;
if
(
val
===
0
)
{
val
=
curCSS
(
elem
,
name
,
name
);
if
(
val
!=
null
)
{
return
val
;
}
}
if
(
val
<
0
||
val
==
null
)
{
return
elem
.
style
[
name
];
}
return
typeof
val
===
"string"
?
val
:
val
+
"px"
;
}
}
},
},
...
...
test/unit/css.js
View file @
7e02cee5
module
(
"css"
);
module
(
"css"
);
test
(
"css(String|Hash)"
,
function
()
{
test
(
"css(String|Hash)"
,
function
()
{
expect
(
4
2
);
expect
(
4
1
);
equals
(
jQuery
(
'#main'
).
css
(
"display"
),
'block'
,
'Check for css property "display"'
);
equals
(
jQuery
(
'#main'
).
css
(
"display"
),
'block'
,
'Check for css property "display"'
);
...
@@ -13,21 +13,19 @@ test("css(String|Hash)", function() {
...
@@ -13,21 +13,19 @@ test("css(String|Hash)", function() {
var
div
=
jQuery
(
"<div>"
);
var
div
=
jQuery
(
"<div>"
);
equals
(
div
.
css
(
"width"
)
,
"0px
"
,
"Width on disconnected node."
);
equals
(
div
.
css
(
"width"
)
||
"auto"
,
"auto
"
,
"Width on disconnected node."
);
equals
(
div
.
css
(
"height"
)
,
"0px
"
,
"Height on disconnected node."
);
equals
(
div
.
css
(
"height"
)
||
"auto"
,
"auto
"
,
"Height on disconnected node."
);
div
.
css
({
width
:
4
,
height
:
4
});
div
.
css
({
width
:
4
,
height
:
4
});
equals
(
div
.
css
(
"width"
),
"4px"
,
"Width on disconnected node."
);
equals
(
div
.
css
(
"width"
),
"4px"
,
"Width on disconnected node."
);
equals
(
div
.
css
(
"height"
),
"4px"
,
"Height on disconnected node."
);
equals
(
div
.
css
(
"height"
),
"4px"
,
"Height on disconnected node."
);
var
div2
=
jQuery
(
"<div style='display:none;'><input type='text'
/><textarea/
></div>"
).
appendTo
(
"body"
);
var
div2
=
jQuery
(
"<div style='display:none;'><input type='text'
style='height:20px;'/><textarea style='height:20px;'/><div style='height:20px;'></div
></div>"
).
appendTo
(
"body"
);
equals
(
div2
.
find
(
"input"
).
css
(
"width"
),
"0px"
,
"Width on hidden input."
);
equals
(
div2
.
find
(
"input"
).
css
(
"height"
),
"20px"
,
"Height on hidden input."
);
equals
(
div2
.
find
(
"input"
).
css
(
"height"
),
"0px"
,
"Height on hidden input."
);
equals
(
div2
.
find
(
"textarea"
).
css
(
"height"
),
"20px"
,
"Height on hidden textarea."
);
equals
(
div2
.
find
(
"div"
).
css
(
"height"
),
"20px"
,
"Height on hidden textarea."
);
equals
(
div2
.
find
(
"textarea"
).
css
(
"width"
),
"0px"
,
"Width on hidden textarea."
);
equals
(
div2
.
find
(
"textarea"
).
css
(
"height"
),
"0px"
,
"Height on hidden textarea."
);
div2
.
remove
();
div2
.
remove
();
...
...
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