Permalink
Browse files

Fix: Selector for attributes with namespace

Close #1388
  • Loading branch information...
sarvaje authored and alrra committed Oct 9, 2018
1 parent d04e94b commit f300d048d0f6ac685045a13cfb13fd2197d0a67f
Showing with 9 additions and 1 deletion.
  1. +9 −1 packages/hint/src/lib/utils/location-helpers.ts
@@ -9,6 +9,14 @@ const escapeQuotes = (text: string): string => {
return text.replace(quotesRegex, '\\$1');
};
/**
* Escape an attribute name with namespace.
* e.g. xmlns:data
*/
const escapeNamespace = (text: string): string => {
return text.replace(':', '\\:');
};
/**
* Creates a CSS selector from a given element using its attributes and the type of node:
*
@@ -28,7 +36,7 @@ const selectorFromElement = (element: IAsyncHTMLElement): string => {
* so we ignore that selector.
*/
if (!attribute.name.includes('.')) {
selector += `[${attribute.name}="${escapeQuotes(attribute.value)}"]`;
selector += `[${escapeNamespace(attribute.name)}="${escapeQuotes(attribute.value)}"]`;
}
}

0 comments on commit f300d04

Please sign in to comment.