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
670e3ff0
Commit
670e3ff0
authored
Aug 29, 2012
by
Mike Sherov
Committed by
Dave Methvin
Aug 29, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #12243, $("col").width() should return the column's width. Close gh-916.
parent
be2899b3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
css.js
src/css.js
+8
-3
dimensions.js
test/unit/dimensions.js
+7
-6
No files found.
src/css.js
View file @
670e3ff0
...
@@ -2,6 +2,9 @@ var curCSS, iframe, iframeDoc,
...
@@ -2,6 +2,9 @@ var curCSS, iframe, iframeDoc,
ralpha
=
/alpha
\([^
)
]
*
\)
/i
,
ralpha
=
/alpha
\([^
)
]
*
\)
/i
,
ropacity
=
/opacity=
([^
)
]
*
)
/
,
ropacity
=
/opacity=
([^
)
]
*
)
/
,
rposition
=
/^
(
top|right|bottom|left
)
$/
,
rposition
=
/^
(
top|right|bottom|left
)
$/
,
// swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
// see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
rdisplayswap
=
/^
(
none|table
(?!
-c
[
ea
])
.+
)
/
,
rmargin
=
/^margin/
,
rmargin
=
/^margin/
,
rnumsplit
=
new
RegExp
(
"^("
+
core_pnum
+
")(.*)$"
,
"i"
),
rnumsplit
=
new
RegExp
(
"^("
+
core_pnum
+
")(.*)$"
,
"i"
),
rnumnonpx
=
new
RegExp
(
"^("
+
core_pnum
+
")(?!px)[a-z%]+$"
,
"i"
),
rnumnonpx
=
new
RegExp
(
"^("
+
core_pnum
+
")(?!px)[a-z%]+$"
,
"i"
),
...
@@ -493,12 +496,14 @@ jQuery.each([ "height", "width" ], function( i, name ) {
...
@@ -493,12 +496,14 @@ jQuery.each([ "height", "width" ], function( i, name ) {
jQuery
.
cssHooks
[
name
]
=
{
jQuery
.
cssHooks
[
name
]
=
{
get
:
function
(
elem
,
computed
,
extra
)
{
get
:
function
(
elem
,
computed
,
extra
)
{
if
(
computed
)
{
if
(
computed
)
{
if
(
elem
.
offsetWidth
!==
0
||
curCSS
(
elem
,
"display"
)
!==
"none"
)
{
// certain elements can have dimension info if we invisibly show them
return
getWidthOrHeight
(
elem
,
name
,
extra
);
// however, it must have a current display style that would benefit from this
}
else
{
if
(
elem
.
offsetWidth
===
0
&&
rdisplayswap
.
test
(
curCSS
(
elem
,
"display"
)
)
)
{
return
jQuery
.
swap
(
elem
,
cssShow
,
function
()
{
return
jQuery
.
swap
(
elem
,
cssShow
,
function
()
{
return
getWidthOrHeight
(
elem
,
name
,
extra
);
return
getWidthOrHeight
(
elem
,
name
,
extra
);
});
});
}
else
{
return
getWidthOrHeight
(
elem
,
name
,
extra
);
}
}
}
}
},
},
...
...
test/unit/dimensions.js
View file @
670e3ff0
...
@@ -292,14 +292,15 @@ test("getting dimensions shouldnt modify runtimeStyle see #9233", function() {
...
@@ -292,14 +292,15 @@ test("getting dimensions shouldnt modify runtimeStyle see #9233", function() {
$div
.
remove
();
$div
.
remove
();
});
});
test
(
"getting dimensions of zero width/height table elements shouldn't alter dimensions"
,
function
()
{
test
(
"table dimensions"
,
2
,
function
()
{
expect
(
1
);
var
table
=
jQuery
(
"<table><colgroup><col/><col/></colgroup><tbody><tr><td></td><td>a</td></tr><tr><td></td><td>a</td></tr></tbody></table>"
).
appendTo
(
"#qunit-fixture"
),
tdElem
=
table
.
find
(
"tr:eq(0) td:eq(0)"
),
var
table
=
jQuery
(
"<table><tbody><tr><td></td><td>a</td></tr><tr><td></td><td>a</td></tr></tbody></table>"
).
appendTo
(
"#qunit-fixture"
),
colElem
=
table
.
find
(
"col:eq(1)"
).
width
(
300
);
elem
=
table
.
find
(
"tr:eq(0) td:eq(0)"
);
table
.
find
(
"td"
).
css
({
"margin"
:
0
,
"padding"
:
0
});
table
.
find
(
"td"
).
css
({
"margin"
:
0
,
"padding"
:
0
});
equal
(
elem
.
width
(),
elem
.
width
(),
"width() doesn't alter dimension values"
);
equal
(
tdElem
.
width
(),
tdElem
.
width
(),
"width() doesn't alter dimension values of empty cells, see #11293"
);
equal
(
colElem
.
width
(),
300
,
"col elements have width(), see #12243"
);
});
});
test
(
"box-sizing:border-box child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #10413"
,
function
()
{
test
(
"box-sizing:border-box child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #10413"
,
function
()
{
...
...
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