diff --git a/packages/pug-parser/index.js b/packages/pug-parser/index.js index abd531ed5..05751bacb 100644 --- a/packages/pug-parser/index.js +++ b/packages/pug-parser/index.js @@ -4,6 +4,12 @@ var assert = require('assert'); var TokenStream = require('token-stream'); var error = require('pug-error'); var inlineTags = require('./lib/inline-tags'); +var inlineTagsObj = {}; +inlineTags.forEach( + function (tag) { + inlineTagsObj[tag] = true; + } +); module.exports = parse; module.exports.Parser = Parser; @@ -1117,7 +1123,7 @@ Parser.prototype = { block: this.emptyBlock(tok.loc.start.line), attrs: [], attributeBlocks: [], - isInline: inlineTags.indexOf(tok.val) !== -1, + isInline: inlineTagsObj.hasOwnProperty(tok.val), line: tok.loc.start.line, column: tok.loc.start.column, filename: this.filename, diff --git a/packages/pug-parser/lib/inline-tags.js b/packages/pug-parser/lib/inline-tags.js index 92cda828c..1eaf14d5d 100644 --- a/packages/pug-parser/lib/inline-tags.js +++ b/packages/pug-parser/lib/inline-tags.js @@ -5,19 +5,53 @@ module.exports = [ 'abbr', 'acronym', 'b', + 'bdi', + 'bdo', + 'big', 'br', + 'button', + 'canvas', + 'cite', 'code', + 'data', + 'datalist', + 'del', + 'dfn', 'em', + 'embed', 'font', 'i', + 'iframe', 'img', + 'input', 'ins', 'kbd', + 'label', 'map', + 'mark', + 'meter', + 'noscript', + 'object', + 'output', + 'picture', + 'progress', + 'ruby', + 's', 'samp', + 'select', + 'slot', 'small', 'span', 'strong', + 'svg', 'sub', 'sup', + 'template', + 'textarea', + 'time', + 'u', + 'tt', + 'var', + 'video', + 'wbr', ]; diff --git a/packages/pug-parser/test/__snapshots__/index.test.js.snap b/packages/pug-parser/test/__snapshots__/index.test.js.snap index 39ab5cbc3..3e1064a32 100644 --- a/packages/pug-parser/test/__snapshots__/index.test.js.snap +++ b/packages/pug-parser/test/__snapshots__/index.test.js.snap @@ -784,7 +784,7 @@ Object { }, "column": 1, "filename": "attrs.tokens.json", - "isInline": false, + "isInline": true, "line": 6, "name": "select", "selfClosing": false, @@ -836,7 +836,7 @@ Object { }, "column": 1, "filename": "attrs.tokens.json", - "isInline": false, + "isInline": true, "line": 10, "name": "input", "selfClosing": false, @@ -1124,7 +1124,7 @@ Object { }, "column": 1, "filename": "attrs.tokens.json", - "isInline": false, + "isInline": true, "line": 17, "name": "select", "selfClosing": false, @@ -1176,7 +1176,7 @@ Object { }, "column": 1, "filename": "attrs.tokens.json", - "isInline": false, + "isInline": true, "line": 21, "name": "input", "selfClosing": false, @@ -6697,7 +6697,7 @@ Object { }, "column": 9, "filename": "escape-test.tokens.json", - "isInline": false, + "isInline": true, "line": 6, "name": "textarea", "selfClosing": false, @@ -8371,7 +8371,7 @@ Object { }, "column": 1, "filename": "html5.tokens.json", - "isInline": false, + "isInline": true, "line": 2, "name": "input", "selfClosing": false, @@ -8405,7 +8405,7 @@ Object { }, "column": 1, "filename": "html5.tokens.json", - "isInline": false, + "isInline": true, "line": 3, "name": "input", "selfClosing": false, @@ -8439,7 +8439,7 @@ Object { }, "column": 1, "filename": "html5.tokens.json", - "isInline": false, + "isInline": true, "line": 4, "name": "input", "selfClosing": false, @@ -13405,7 +13405,7 @@ Object { }, "column": 5, "filename": "mixin.blocks.tokens.json", - "isInline": false, + "isInline": true, "line": 6, "name": "input", "selfClosing": false, @@ -13496,7 +13496,7 @@ Object { }, "column": 7, "filename": "mixin.blocks.tokens.json", - "isInline": false, + "isInline": true, "line": 12, "name": "input", "selfClosing": false, @@ -13530,7 +13530,7 @@ Object { }, "column": 7, "filename": "mixin.blocks.tokens.json", - "isInline": false, + "isInline": true, "line": 13, "name": "input", "selfClosing": false, @@ -13626,7 +13626,7 @@ Object { }, "column": 7, "filename": "mixin.blocks.tokens.json", - "isInline": false, + "isInline": true, "line": 18, "name": "input", "selfClosing": false, @@ -13660,7 +13660,7 @@ Object { }, "column": 7, "filename": "mixin.blocks.tokens.json", - "isInline": false, + "isInline": true, "line": 19, "name": "input", "selfClosing": false, @@ -18913,7 +18913,7 @@ Object { }, "column": 3, "filename": "text-block.tokens.json", - "isInline": false, + "isInline": true, "line": 3, "name": "input", "selfClosing": false, @@ -18924,7 +18924,7 @@ Object { }, "column": 1, "filename": "text-block.tokens.json", - "isInline": false, + "isInline": true, "line": 2, "name": "label", "selfClosing": false, @@ -18972,7 +18972,7 @@ Object { }, "column": 3, "filename": "text-block.tokens.json", - "isInline": false, + "isInline": true, "line": 6, "name": "input", "selfClosing": false, @@ -18983,7 +18983,7 @@ Object { }, "column": 1, "filename": "text-block.tokens.json", - "isInline": false, + "isInline": true, "line": 5, "name": "label", "selfClosing": false, diff --git a/packages/pug/test/cases/attrs.html b/packages/pug/test/cases/attrs.html index 9dcaee58c..5cf1af30d 100644 --- a/packages/pug/test/cases/attrs.html +++ b/packages/pug/test/cases/attrs.html @@ -1,14 +1,8 @@ -contactsave - - - -contactsave -contactsave - + diff --git a/packages/pug/test/cases/escape-test.html b/packages/pug/test/cases/escape-test.html index 15e72d92e..858f56339 100644 --- a/packages/pug/test/cases/escape-test.html +++ b/packages/pug/test/cases/escape-test.html @@ -3,7 +3,5 @@ escape-test - - - + diff --git a/packages/pug/test/cases/html5.html b/packages/pug/test/cases/html5.html index 83a553af4..9daacbba2 100644 --- a/packages/pug/test/cases/html5.html +++ b/packages/pug/test/cases/html5.html @@ -1,4 +1 @@ - - - - \ No newline at end of file + diff --git a/packages/pug/test/cases/mixin.blocks.html b/packages/pug/test/cases/mixin.blocks.html index def5c6f92..12b55c67a 100644 --- a/packages/pug/test/cases/mixin.blocks.html +++ b/packages/pug/test/cases/mixin.blocks.html @@ -1,25 +1,18 @@ -
- - - +
-
- - - +
-
- +
@@ -31,4 +24,4 @@
123 -
\ No newline at end of file + diff --git a/packages/pug/test/cases/text-block.html b/packages/pug/test/cases/text-block.html index fae8caa93..5a1ed48c1 100644 --- a/packages/pug/test/cases/text-block.html +++ b/packages/pug/test/cases/text-block.html @@ -1,6 +1 @@ - - \ No newline at end of file +