-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: multi elements support for tag
- Loading branch information
Showing
2 changed files
with
19 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
import {sanitizeSelectorItem} from './utilities-selectors' | ||
import {CssSelector} from './types' | ||
import { | ||
sanitizeSelectorItem, | ||
sanitizeSelectorNeedle | ||
} from './utilities-selectors'; | ||
import {CssSelector, SelectorNeedle} from './types'; | ||
|
||
/** | ||
* Get tag selector for an element. | ||
*/ | ||
export function getTagSelector (element: Element): Array<CssSelector> { | ||
return [sanitizeSelectorItem(element.tagName.toLowerCase())] | ||
export function getTagSelector (needle: SelectorNeedle): Array<CssSelector> { | ||
const elements = sanitizeSelectorNeedle(needle) | ||
const selectors = [...new Set(elements.map((element) => { | ||
return sanitizeSelectorItem(element.tagName.toLowerCase()) | ||
}))] | ||
return (selectors.length === 0 || selectors.length > 1) ? [] : [selectors[0]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters