Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (node instanceof Element) {
const tagDefinition = getHtmlTagDefinition(
isTagNameCaseSensitive ? node.name : node.name.toLowerCase()
);
if (
!node.namespace ||
node.namespace === tagDefinition.implicitNamespacePrefix
) {
node.tagDefinition = tagDefinition;
} else {
node.tagDefinition = getHtmlTagDefinition(""); // the default one
}
}
};
visitAll(
new (class extends RecursiveVisitor {
visit(node) {
addType(node);
restoreNameAndValue(node);
addTagDefinition(node);
normalizeName(node);
fixSourceSpan(node);
}
})(),
rootNodes
);
return rootNodes;
}
const addTagDefinition = node => {
if (node instanceof Element) {
const tagDefinition = getHtmlTagDefinition(
isTagNameCaseSensitive ? node.name : node.name.toLowerCase()
);
if (
!node.namespace ||
node.namespace === tagDefinition.implicitNamespacePrefix
) {
node.tagDefinition = tagDefinition;
} else {
node.tagDefinition = getHtmlTagDefinition(""); // the default one
}
}
};
const addTagDefinition = node => {
if (node instanceof Element) {
const tagDefinition = getHtmlTagDefinition(
isTagNameCaseSensitive ? node.name : node.name.toLowerCase()
);
if (
!node.namespace ||
node.namespace === tagDefinition.implicitNamespacePrefix
) {
node.tagDefinition = tagDefinition;
} else {
node.tagDefinition = getHtmlTagDefinition(""); // the default one
}
}
};
visitAll,
Attribute,
CDATA,
Comment,
DocType,
Element,
Text
} = require("angular-html-parser/lib/compiler/src/ml_parser/ast");
const {
ParseSourceSpan
} = require("angular-html-parser/lib/compiler/src/parse_util");
const {
getHtmlTagDefinition
} = require("angular-html-parser/lib/compiler/src/ml_parser/html_tags");
const { rootNodes, errors } = parser.parse(input, {
canSelfClose: recognizeSelfClosing,
allowHtmComponentClosingTags,
isTagNameCaseSensitive
});
if (errors.length !== 0) {
const { msg, span } = errors[0];
const { line, col } = span.start;
throw createError(msg, { start: { line: line + 1, column: col + 1 } });
}
const addType = node => {
if (node instanceof Attribute) {
node.type = "attribute";
} else if (node instanceof CDATA) {
node.type = "cdata";
const fixSourceSpan = node => {
if (node.sourceSpan && node.endSourceSpan) {
node.sourceSpan = new ParseSourceSpan(
node.sourceSpan.start,
node.endSourceSpan.end
);
}
};