Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

getHtmlTagDefinition does not return tag definition if given tag name is constructor, toString, etc... #52224

Copy link
Copy link
@sosukesuzuki

Description

@sosukesuzuki
Issue body actions

Which @angular/* package(s) are the source of the bug?

compiler

Is this a regression?

No

Description

getHtmlTagDefinition returns a tag definition for given HTML tag name. If given tag name is unknown, it should return default tag definition new HtmlTagDefinition({canSelfClose: true}).

However, it does not return the default tag definition for some tag names(constructor, toString, etc...), this is because the table of tag definitions is defined as a JavaScript object.

Code example:
import * as ac from "@angular/compiler";

const KNOWN_TAG_DIV = "div";
const UNKNOWN_TAG_FOO = "foo";
const UNKNOWN_TAG_CONSTRUCTOR = "constructor";
const UNKNOWN_TAG_TOSTRING = "toString";

console.log(ac.getHtmlTagDefinition(KNOWN_TAG_DIV));
// HtmlTagDefinition {
//   closedByChildren: {},
//   closedByParent: false,
//   isVoid: false,
//   implicitNamespacePrefix: null,
//   contentType: 2,
//   ignoreFirstLf: false,
//   preventNamespaceInheritance: false,
//   canSelfClose: false
// }

console.log(ac.getHtmlTagDefinition(UNKNOWN_TAG_FOO));
// HtmlTagDefinition {
//   closedByChildren: {},
//   closedByParent: false,
//   isVoid: false,
//   implicitNamespacePrefix: null,
//   contentType: 2,
//   ignoreFirstLf: false,
//   preventNamespaceInheritance: false,
//   canSelfClose: true
// }

console.log(ac.getHtmlTagDefinition(UNKNOWN_TAG_CONSTRUCTOR));
// [Function: Object]

console.log(ac.getHtmlTagDefinition(UNKNOWN_TAG_TOSTRING));
// [Function: toString]

Please provide a link to a minimal reproduction of the bug

https://github.com/sosukesuzuki/angular-get-html-tag-definition-bug

Please provide the exception or error you saw

// N/A

Please provide the environment you discovered this bug in (run ng version)

{
  "@angular/compiler": "^16.2.9"
}

Anything else?

This is from prettier/prettier#15511

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.