angular-html-parser
Advanced tools
Comparing version 3.0.0 to 4.0.0
@@ -18,3 +18,3 @@ /** | ||
preventNamespaceInheritance: boolean; | ||
constructor({ closedByChildren, implicitNamespacePrefix, contentType, closedByParent, isVoid, ignoreFirstLf, preventNamespaceInheritance }?: { | ||
constructor({ closedByChildren, implicitNamespacePrefix, contentType, closedByParent, isVoid, ignoreFirstLf, preventNamespaceInheritance, canSelfClose, }?: { | ||
closedByChildren?: string[]; | ||
@@ -30,2 +30,3 @@ closedByParent?: boolean; | ||
preventNamespaceInheritance?: boolean; | ||
canSelfClose?: boolean; | ||
}); | ||
@@ -32,0 +33,0 @@ isClosedByChild(name: string): boolean; |
@@ -8,8 +8,8 @@ /** | ||
*/ | ||
import { TagContentType } from "./tags.js"; | ||
import { DomElementSchemaRegistry } from "../schema/dom_element_schema_registry.js"; | ||
import { getNsPrefix, TagContentType } from "./tags.js"; | ||
export class HtmlTagDefinition { | ||
constructor({ closedByChildren, implicitNamespacePrefix, contentType = TagContentType.PARSABLE_DATA, closedByParent = false, isVoid = false, ignoreFirstLf = false, preventNamespaceInheritance = false } = {}) { | ||
constructor({ closedByChildren, implicitNamespacePrefix, contentType = TagContentType.PARSABLE_DATA, closedByParent = false, isVoid = false, ignoreFirstLf = false, preventNamespaceInheritance = false, canSelfClose = false, } = {}) { | ||
this.closedByChildren = {}; | ||
this.closedByParent = false; | ||
this.canSelfClose = false; | ||
if (closedByChildren && closedByChildren.length > 0) { | ||
@@ -24,2 +24,3 @@ closedByChildren.forEach(tagName => this.closedByChildren[tagName] = true); | ||
this.preventNamespaceInheritance = preventNamespaceInheritance; | ||
this.canSelfClose = canSelfClose ?? isVoid; | ||
} | ||
@@ -37,3 +38,3 @@ isClosedByChild(name) { | ||
} | ||
let _DEFAULT_TAG_DEFINITION; | ||
let DEFAULT_TAG_DEFINITION; | ||
// see https://www.w3.org/TR/html51/syntax.html#optional-tags | ||
@@ -44,3 +45,3 @@ // This implementation does not fully conform to the HTML5 spec. | ||
if (!TAG_DEFINITIONS) { | ||
_DEFAULT_TAG_DEFINITION = new HtmlTagDefinition(); | ||
DEFAULT_TAG_DEFINITION = new HtmlTagDefinition({ canSelfClose: true }); | ||
TAG_DEFINITIONS = { | ||
@@ -109,2 +110,7 @@ 'base': new HtmlTagDefinition({ isVoid: true }), | ||
}; | ||
new DomElementSchemaRegistry().allKnownElementNames().forEach(knownTagName => { | ||
if (!TAG_DEFINITIONS.hasOwnProperty(knownTagName) && getNsPrefix(knownTagName) === null) { | ||
TAG_DEFINITIONS[knownTagName] = new HtmlTagDefinition({ canSelfClose: false }); | ||
} | ||
}); | ||
} | ||
@@ -114,3 +120,3 @@ // We have to make both a case-sensitive and a case-insensitive lookup, because | ||
return TAG_DEFINITIONS[tagName] ?? // TAG_DEFINITIONS[tagName.toLowerCase()] ?? -- angular-html-parser modification | ||
_DEFAULT_TAG_DEFINITION; | ||
DEFAULT_TAG_DEFINITION; | ||
} |
@@ -281,3 +281,3 @@ /** | ||
if (!(this.canSelfClose || tagDef.canSelfClose || getNsPrefix(fullName) !== null || tagDef.isVoid)) { | ||
this.errors.push(TreeError.create(fullName, startTagToken.sourceSpan, `Only void and foreign elements can be self closed "${startTagToken.parts[1]}"`)); | ||
this.errors.push(TreeError.create(fullName, startTagToken.sourceSpan, `Only void, custom and foreign elements can be self closed "${startTagToken.parts[1]}"`)); | ||
} | ||
@@ -284,0 +284,0 @@ } |
{ | ||
"name": "angular-html-parser", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"description": "A HTML parser extracted from Angular with some modifications", | ||
@@ -27,3 +27,3 @@ "main": "./lib/angular-html-parser/src/index.js", | ||
"devDependencies": { | ||
"@types/jscodeshift": "0.11.5", | ||
"@types/jscodeshift": "0.11.6", | ||
"del-cli": "5.0.0", | ||
@@ -34,4 +34,4 @@ "jasmine": "4.5.0", | ||
"ts-node": "10.9.1", | ||
"tsconfig-paths": "4.1.0", | ||
"typescript": "4.9.3" | ||
"tsconfig-paths": "4.1.2", | ||
"typescript": "4.9.4" | ||
}, | ||
@@ -38,0 +38,0 @@ "engines": { |
Sorry, the diff of this file is too big to display
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
1150699
113343
45
7024
3