test-drive
Advanced tools
Comparing version 0.0.52 to 0.0.53
@@ -10,3 +10,7 @@ "use strict"; | ||
var selector = selectors[0], rest = selectors.slice(1); | ||
var elementList = parentElement.querySelectorAll("[" + attrName + "~=\"" + selector + "\"]"); | ||
var selectorExpr = "[" + attrName + "~=\"" + selector + "\"]"; | ||
var elementList = Array.prototype.slice.call(parentElement.querySelectorAll(selectorExpr)); | ||
if (parentElement.matches(selectorExpr)) { | ||
elementList.unshift(parentElement); | ||
} | ||
if (elementList.length === 0) { | ||
@@ -13,0 +17,0 @@ return null; |
{ | ||
"name": "test-drive", | ||
"version": "0.0.52", | ||
"version": "0.0.53", | ||
"description": "Opinionated library for writing web component tests", | ||
@@ -5,0 +5,0 @@ "main": "./dist/src/index.js", |
@@ -5,4 +5,8 @@ export function selectDom(container: Element, attrName: string = 'data-automation-id') { | ||
const [selector, ...rest] = selectors; | ||
const elementList = parentElement.querySelectorAll(`[${attrName}~="${selector}"]`); | ||
if (elementList.length === 0) { | ||
const selectorExpr = `[${attrName}~="${selector}"]`; | ||
const elementList: T[] = Array.prototype.slice.call(parentElement.querySelectorAll(selectorExpr)); | ||
if(parentElement.matches(selectorExpr)) { | ||
elementList.unshift(parentElement as T); | ||
} | ||
if(elementList.length === 0) { | ||
return null; | ||
@@ -9,0 +13,0 @@ } else if (elementList.length === 1) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
3226847
13242