Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
038f36c0
...
038f36c0c08b4beb74e4022fe91692ed15478e9a
authored
2014-05-11 10:58:15 -0700
by
Ryan Frederick
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
refs #917 - fixed selector capture unaware of page zoom factor
1 parent
e14544ab
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
2 deletions
modules/casper.js
modules/casper.js
View file @
038f36c
...
...
@@ -1047,7 +1047,15 @@ Casper.prototype.getElementBounds = function getElementBounds(selector) {
if
(
!
this
.
exists
(
selector
))
{
throw
new
CasperError
(
"No element matching selector found: "
+
selector
);
}
var
zoomFactor
=
this
.
page
.
zoomFactor
||
1
;
var
clipRect
=
this
.
callUtils
(
"getElementBounds"
,
selector
);
if
(
zoomFactor
!==
1
)
{
for
(
var
prop
in
clipRect
)
{
if
(
clipRect
.
hasOwnProperty
(
prop
))
{
clipRect
[
prop
]
=
clipRect
[
prop
]
*
zoomFactor
;
}
}
}
if
(
!
utils
.
isClipRect
(
clipRect
))
{
throw
new
CasperError
(
'Could not fetch boundaries for element matching selector: '
+
selector
);
}
...
...
@@ -1090,13 +1098,24 @@ Casper.prototype.getElementsInfo = function getElementsInfo(selector) {
* @param String selector A DOM CSS3/XPath selector
* @return Array
*/
Casper
.
prototype
.
getElementsBounds
=
function
getElementBounds
(
selector
)
{
Casper
.
prototype
.
getElementsBounds
=
function
getElement
s
Bounds
(
selector
)
{
"use strict"
;
this
.
checkStarted
();
if
(
!
this
.
exists
(
selector
))
{
throw
new
CasperError
(
"No element matching selector found: "
+
selector
);
}
return
this
.
callUtils
(
"getElementsBounds"
,
selector
);
var
zoomFactor
=
this
.
page
.
zoomFactor
||
1
;
var
clipRects
=
this
.
callUtils
(
"getElementsBounds"
,
selector
);
if
(
zoomFactor
!==
1
)
{
Array
.
prototype
.
forEach
.
call
(
clipRects
,
function
(
clipRect
)
{
for
(
var
prop
in
clipRect
)
{
if
(
clipRect
.
hasOwnProperty
(
prop
))
{
clipRect
[
prop
]
=
clipRect
[
prop
]
*
zoomFactor
;
}
}
});
}
return
clipRects
;
};
/**
...
...
Please
register
or
sign in
to post a comment