angular-html-parser
Advanced tools
Comparing version
@@ -70,6 +70,7 @@ /** | ||
children: Node[]; | ||
readonly isSelfClosing: boolean; | ||
startSourceSpan: ParseSourceSpan; | ||
endSourceSpan: ParseSourceSpan | null; | ||
nameSpan: ParseSourceSpan | null; | ||
constructor(name: string, attrs: Attribute[], directives: Directive[], children: Node[], sourceSpan: ParseSourceSpan, startSourceSpan: ParseSourceSpan, endSourceSpan?: ParseSourceSpan | null, nameSpan?: ParseSourceSpan | null, i18n?: I18nMeta); | ||
constructor(name: string, attrs: Attribute[], directives: Directive[], children: Node[], isSelfClosing: boolean, sourceSpan: ParseSourceSpan, startSourceSpan: ParseSourceSpan, endSourceSpan?: ParseSourceSpan | null, nameSpan?: ParseSourceSpan | null, i18n?: I18nMeta); | ||
visit(visitor: Visitor, context: any): any; | ||
@@ -110,5 +111,6 @@ readonly type = "element"; | ||
readonly children: Node[]; | ||
readonly isSelfClosing: boolean; | ||
readonly startSourceSpan: ParseSourceSpan; | ||
endSourceSpan: ParseSourceSpan | null; | ||
constructor(componentName: string, tagName: string | null, fullName: string, attrs: Attribute[], directives: Directive[], children: Node[], sourceSpan: ParseSourceSpan, startSourceSpan: ParseSourceSpan, endSourceSpan?: ParseSourceSpan | null, i18n?: I18nMeta); | ||
constructor(componentName: string, tagName: string | null, fullName: string, attrs: Attribute[], directives: Directive[], children: Node[], isSelfClosing: boolean, sourceSpan: ParseSourceSpan, startSourceSpan: ParseSourceSpan, endSourceSpan?: ParseSourceSpan | null, i18n?: I18nMeta); | ||
visit(visitor: Visitor, context: any): any; | ||
@@ -115,0 +117,0 @@ readonly type = "component"; |
@@ -80,3 +80,3 @@ /** | ||
export class Element extends NodeWithI18n { | ||
constructor(name, attrs, directives, children, sourceSpan, startSourceSpan, endSourceSpan = null, nameSpan = null, i18n) { | ||
constructor(name, attrs, directives, children, isSelfClosing, sourceSpan, startSourceSpan, endSourceSpan = null, nameSpan = null, i18n) { | ||
super(sourceSpan, i18n); | ||
@@ -87,2 +87,3 @@ this.name = name; | ||
this.children = children; | ||
this.isSelfClosing = isSelfClosing; | ||
this.startSourceSpan = startSourceSpan; | ||
@@ -133,3 +134,3 @@ this.endSourceSpan = endSourceSpan; | ||
export class Component extends NodeWithI18n { | ||
constructor(componentName, tagName, fullName, attrs, directives, children, sourceSpan, startSourceSpan, endSourceSpan = null, i18n) { | ||
constructor(componentName, tagName, fullName, attrs, directives, children, isSelfClosing, sourceSpan, startSourceSpan, endSourceSpan = null, i18n) { | ||
super(sourceSpan, i18n); | ||
@@ -142,2 +143,3 @@ this.componentName = componentName; | ||
this.children = children; | ||
this.isSelfClosing = isSelfClosing; | ||
this.startSourceSpan = startSourceSpan; | ||
@@ -144,0 +146,0 @@ this.endSourceSpan = endSourceSpan; |
@@ -329,3 +329,3 @@ /** | ||
const nameSpan = new ParseSourceSpan(startTagToken.sourceSpan.start.moveBy(1), startTagToken.sourceSpan.end); | ||
const el = new html.Element(fullName, attrs, directives, [], span, startSpan, undefined, nameSpan); | ||
const el = new html.Element(fullName, attrs, directives, [], selfClosing, span, startSpan, undefined, nameSpan); | ||
const parent = this._getContainer(); | ||
@@ -359,3 +359,3 @@ const isClosedByChild = parent !== null && !!this._getTagDefinition(parent)?.isClosedByChild(el.name); | ||
const startSpan = new ParseSourceSpan(startToken.sourceSpan.start, end, startToken.sourceSpan.fullStart); | ||
const node = new html.Component(componentName, tagName, fullName, attrs, directives, [], span, startSpan, undefined); | ||
const node = new html.Component(componentName, tagName, fullName, attrs, directives, [], selfClosing, span, startSpan, undefined); | ||
const parent = this._getContainer(); | ||
@@ -362,0 +362,0 @@ const isClosedByChild = parent !== null && |
@@ -67,3 +67,3 @@ /** | ||
if (Array.isArray(token)) { | ||
return '[' + token.map(stringify).join(', ') + ']'; | ||
return `[${token.map(stringify).join(', ')}]`; | ||
} | ||
@@ -73,8 +73,6 @@ if (token == null) { | ||
} | ||
if (token.overriddenName) { | ||
return `${token.overriddenName}`; | ||
const name = token.overriddenName || token.name; | ||
if (name) { | ||
return `${name}`; | ||
} | ||
if (token.name) { | ||
return `${token.name}`; | ||
} | ||
if (!token.toString) { | ||
@@ -85,8 +83,8 @@ return 'object'; | ||
// see https://github.com/angular/angular/issues/23440 | ||
const res = token.toString(); | ||
if (res == null) { | ||
return '' + res; | ||
const result = token.toString(); | ||
if (result == null) { | ||
return '' + result; | ||
} | ||
const newLineIndex = res.indexOf('\n'); | ||
return newLineIndex === -1 ? res : res.substring(0, newLineIndex); | ||
const newLineIndex = result.indexOf('\n'); | ||
return newLineIndex >= 0 ? result.slice(0, newLineIndex) : result; | ||
} | ||
@@ -93,0 +91,0 @@ export class Version { |
{ | ||
"name": "angular-html-parser", | ||
"version": "9.1.0", | ||
"version": "9.1.1", | ||
"description": "A HTML parser extracted from Angular with some modifications", | ||
@@ -32,9 +32,9 @@ "repository": "https://github.com/prettier/angular-html-parser/blob/HEAD/packages/angular-html-parser", | ||
"devDependencies": { | ||
"@types/node": "22.14.1", | ||
"@vitest/coverage-v8": "3.1.1", | ||
"@types/node": "22.15.21", | ||
"@vitest/coverage-v8": "3.1.4", | ||
"del-cli": "6.0.0", | ||
"jasmine": "5.6.0", | ||
"jasmine": "5.7.1", | ||
"jscodeshift": "17.3.0", | ||
"prettier": "3.5.3", | ||
"release-it": "18.1.2", | ||
"release-it": "19.0.2", | ||
"standard-version": "9.5.0", | ||
@@ -44,3 +44,3 @@ "ts-node": "10.9.2", | ||
"typescript": "5.8.3", | ||
"vitest": "3.1.1" | ||
"vitest": "3.1.4" | ||
}, | ||
@@ -47,0 +47,0 @@ "engines": { |
@@ -11,3 +11,3 @@ This project incorporates third party material from the projects listed below. | ||
Copyright (c) 2014-2018 Google, Inc. http://angular.io | ||
Copyright (c) 2010-2025 Google LLC. https://angular.dev/license | ||
@@ -14,0 +14,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
317824
0.08%8164
0.04%