Skip to content

Commit

Permalink
parser: delete slash token parsing
Browse files Browse the repository at this point in the history
The parser and renderer will know which tags are self-closing.
  • Loading branch information
matheusmoreira committed Sep 8, 2023
1 parent 44ee632 commit 2790625
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 304 deletions.
17 changes: 3 additions & 14 deletions packages/parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,6 @@ Parser.prototype = {
var tag = {
type: 'InterpolatedTag',
expr: tok.val,
selfClosing: false,
block: this.emptyBlock(tok.loc.start.line),
attrs: [],
attributeBlocks: [],
Expand All @@ -758,7 +757,7 @@ Parser.prototype = {
filename: this.filename,
};

return this.tag(tag, {selfClosingAllowed: true});
return this.tag(tag);
},

/**
Expand All @@ -770,7 +769,6 @@ Parser.prototype = {
var tag = {
type: 'Tag',
name: tok.val,
selfClosing: false,
block: this.emptyBlock(tok.loc.start.line),
attrs: [],
attributeBlocks: [],
Expand All @@ -780,7 +778,7 @@ Parser.prototype = {
filename: this.filename,
};

return this.tag(tag, {selfClosingAllowed: true});
return this.tag(tag);
},

/**
Expand All @@ -790,7 +788,6 @@ Parser.prototype = {
tag: function(tag, options) {
var seenAttrs = false;
var attributeNames = [];
var selfClosingAllowed = options && options.selfClosingAllowed;
// (attrs | class | id)*
out: while (true) {
switch (this.peek().type) {
Expand Down Expand Up @@ -869,12 +866,6 @@ Parser.prototype = {
case 'start-pipeless-text':
case 'end-interpolation':
break;
case 'slash':
if (selfClosingAllowed) {
this.advance();
tag.selfClosing = true;
break;
}
default:
var pluginResult = this.runPlugin(
'tagTokens',
Expand All @@ -887,9 +878,7 @@ Parser.prototype = {
'INVALID_TOKEN',
'Unexpected token `' +
this.peek().type +
'` expected `text`, `:`' +
(selfClosingAllowed ? ', `slash`' : '') +
', `newline` or `eos`',
'` expected `text`, `:`, `newline` or `eos`',
this.peek()
);
}
Expand Down
Loading

0 comments on commit 2790625

Please sign in to comment.