Skip to content

Commit af49a5e

Browse files
authored
[atoms] use css locators in dom.js (#13430)
1 parent 3184040 commit af49a5e

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

javascript/atoms/BUILD.bazel

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ closure_js_library(
119119
deps = [
120120
":bot",
121121
":color",
122+
":css",
122123
":domcore",
123124
":json",
124125
":useragent",
125-
":xpath",
126126
"@io_bazel_rules_closure//closure/library",
127127
],
128128
)
@@ -239,7 +239,7 @@ closure_js_library(
239239
name = "locators",
240240
srcs = glob(
241241
["locators/*.js"],
242-
exclude = ["locators/xpath.js"],
242+
exclude = ["locators/css.js"],
243243
),
244244
suppress = [
245245
"JSC_IMPLICITLY_NULLABLE_JSDOC",
@@ -250,11 +250,12 @@ closure_js_library(
250250
],
251251
deps = [
252252
":bot",
253+
":css",
253254
":dom",
254255
":errors",
255256
":json",
256257
":useragent",
257-
":xpath",
258+
"//third_party/js/wgxpath",
258259
"@io_bazel_rules_closure//closure/library",
259260
],
260261
)
@@ -289,8 +290,8 @@ closure_js_library(
289290
)
290291

291292
closure_js_library(
292-
name = "xpath",
293-
srcs = ["locators/xpath.js"],
293+
name = "css",
294+
srcs = ["locators/css.js"],
294295
suppress = [
295296
"JSC_IMPLICITLY_NULLABLE_JSDOC",
296297
"JSC_STRICT_INEXISTENT_PROPERTY",
@@ -300,7 +301,7 @@ closure_js_library(
300301
deps = [
301302
":bot",
302303
":errors",
303-
"//third_party/js/wgxpath",
304+
":useragent",
304305
"@io_bazel_rules_closure//closure/library",
305306
],
306307
)
@@ -331,6 +332,7 @@ closure_js_deps(
331332
":action",
332333
":bot",
333334
":color",
335+
":css",
334336
":devices",
335337
":dom",
336338
":domcore",
@@ -343,7 +345,6 @@ closure_js_deps(
343345
":test_util",
344346
":useragent",
345347
":window",
346-
":xpath",
347348
],
348349
)
349350

javascript/atoms/dom.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ goog.provide('bot.dom');
2424
goog.require('bot');
2525
goog.require('bot.color');
2626
goog.require('bot.dom.core');
27-
goog.require('bot.locators.xpath');
27+
goog.require('bot.locators.css');
2828
goog.require('bot.userAgent');
2929
goog.require('goog.array');
3030
goog.require('goog.dom');
@@ -878,15 +878,12 @@ bot.dom.maybeFindImageMap_ = function(elem) {
878878
if (map && map.name) {
879879
var mapDoc = goog.dom.getOwnerDocument(map);
880880

881-
// The "//*" XPath syntax can confuse the closure compiler, so we use
882-
// the "/descendant::*" syntax instead.
883-
// TODO: Try to find a reproducible case for the compiler bug.
884881
// TODO: Restrict to applet, img, input:image, and object nodes.
885-
var imageXpath = '/descendant::*[@usemap = "#' + map.name + '"]';
882+
var locator = '*[usemap="#' + map.name + '"]';
886883

887884
// TODO: Break dependency of bot.locators on bot.dom,
888885
// so bot.locators.findElement can be called here instead.
889-
image = bot.locators.xpath.single(imageXpath, mapDoc);
886+
image = bot.locators.css.single(locator, mapDoc);
890887

891888
if (image) {
892889
rect = bot.dom.getClientRect(image);

0 commit comments

Comments
 (0)