mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-06-10 15:19:03 +00:00
Improve getElementPosition()
for handling elements within a shadow root
Some checks are pending
CodeQL / Analyze (javascript) (push) Waiting to run
Some checks are pending
CodeQL / Analyze (javascript) (push) Waiting to run
This commit is contained in:
parent
710acc4bbd
commit
a81ccc0efa
|
@ -759,6 +759,31 @@ var ChromeObject = function() {
|
|||
}
|
||||
};
|
||||
|
||||
this.getDeepElementPosition = function(selectors) {
|
||||
var result = this.getEvaluatedValue('(function() { var rect = __getDocument().' + this.getShadowRootSelector(selectors) + '.getBoundingClientRect(); return [parseInt(rect.left), parseInt(rect.top), parseInt(__getWindow().pageXOffset + rect.left), parseInt(__getWindow().pageYOffset + rect.top), parseInt(rect.width), parseInt(rect.height)].join(","); })();');
|
||||
var pos = result.split(',');
|
||||
|
||||
if (pos.length == 6) {
|
||||
return {
|
||||
"x": parseInt(pos[0]),
|
||||
"y": parseInt(pos[1]),
|
||||
"a": parseInt(pos[2]),
|
||||
"b": parseInt(pos[3]),
|
||||
"w": parseInt(pos[4]),
|
||||
"h": parseInt(pos[5])
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
"x": -1,
|
||||
"y": -1,
|
||||
"a": -1,
|
||||
"b": -1,
|
||||
"g": -1,
|
||||
"d": -1
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
this.getElementPositionByText = function(selector, searchText) {
|
||||
var result;
|
||||
var pos = -1;
|
||||
|
@ -1423,7 +1448,7 @@ exports.startDebugInPrivate = function(url, proxy, profileName, debuggingPort, i
|
|||
;
|
||||
};
|
||||
|
||||
exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.4.15";
|
||||
exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.4.16";
|
||||
exports.AUTHOR = "abuse@catswords.net";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user