Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle self-closing tags in liteDOM. #328 #370

Merged
merged 1 commit into from
Nov 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ts/adaptors/lite/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class LiteParser implements MinDOMParser<LiteDocument> {
//
// Get the child to be added to the node
//
const kind = tag.match(/<(.*?)[\s\n>]/)[1].toLowerCase();
const kind = tag.match(/<(.*?)[\s\n>/]/)[1].toLowerCase();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should that not be

Suggested change
const kind = tag.match(/<(.*?)[\s\n>/]/)[1].toLowerCase();
const kind = tag.match(/<(.*?)[\s\n/>]/)[1].toLowerCase();

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order of the characters in the [...] doesn't matter. It just matches up to any one of the enclosed characters. So it is correct as is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I now realise that it is only any of the four characters.

const child = adaptor.node(kind) as LiteElement;
//
// Split out the tag attributes as an array of space, name, value1, value3, value3,
Expand All @@ -211,7 +211,7 @@ export class LiteParser implements MinDOMParser<LiteDocument> {
// Otherwise, the child tag becames the parent node to which
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

// new tags are added
//
if (!SELF_CLOSING[kind]) {
if (!SELF_CLOSING[kind] && !tag.match(/\/>$/)) {
if (PCDATA[kind]) {
this.handlePCDATA(adaptor, child, kind, parts);
} else {
Expand Down