Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion packages/pug-parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
34 changes: 34 additions & 0 deletions packages/pug-parser/lib/inline-tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
];
34 changes: 17 additions & 17 deletions packages/pug-parser/test/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ Object {
},
"column": 1,
"filename": "attrs.tokens.json",
"isInline": false,
"isInline": true,
"line": 6,
"name": "select",
"selfClosing": false,
Expand Down Expand Up @@ -836,7 +836,7 @@ Object {
},
"column": 1,
"filename": "attrs.tokens.json",
"isInline": false,
"isInline": true,
"line": 10,
"name": "input",
"selfClosing": false,
Expand Down Expand Up @@ -1124,7 +1124,7 @@ Object {
},
"column": 1,
"filename": "attrs.tokens.json",
"isInline": false,
"isInline": true,
"line": 17,
"name": "select",
"selfClosing": false,
Expand Down Expand Up @@ -1176,7 +1176,7 @@ Object {
},
"column": 1,
"filename": "attrs.tokens.json",
"isInline": false,
"isInline": true,
"line": 21,
"name": "input",
"selfClosing": false,
Expand Down Expand Up @@ -6697,7 +6697,7 @@ Object {
},
"column": 9,
"filename": "escape-test.tokens.json",
"isInline": false,
"isInline": true,
"line": 6,
"name": "textarea",
"selfClosing": false,
Expand Down Expand Up @@ -8371,7 +8371,7 @@ Object {
},
"column": 1,
"filename": "html5.tokens.json",
"isInline": false,
"isInline": true,
"line": 2,
"name": "input",
"selfClosing": false,
Expand Down Expand Up @@ -8405,7 +8405,7 @@ Object {
},
"column": 1,
"filename": "html5.tokens.json",
"isInline": false,
"isInline": true,
"line": 3,
"name": "input",
"selfClosing": false,
Expand Down Expand Up @@ -8439,7 +8439,7 @@ Object {
},
"column": 1,
"filename": "html5.tokens.json",
"isInline": false,
"isInline": true,
"line": 4,
"name": "input",
"selfClosing": false,
Expand Down Expand Up @@ -13405,7 +13405,7 @@ Object {
},
"column": 5,
"filename": "mixin.blocks.tokens.json",
"isInline": false,
"isInline": true,
"line": 6,
"name": "input",
"selfClosing": false,
Expand Down Expand Up @@ -13496,7 +13496,7 @@ Object {
},
"column": 7,
"filename": "mixin.blocks.tokens.json",
"isInline": false,
"isInline": true,
"line": 12,
"name": "input",
"selfClosing": false,
Expand Down Expand Up @@ -13530,7 +13530,7 @@ Object {
},
"column": 7,
"filename": "mixin.blocks.tokens.json",
"isInline": false,
"isInline": true,
"line": 13,
"name": "input",
"selfClosing": false,
Expand Down Expand Up @@ -13626,7 +13626,7 @@ Object {
},
"column": 7,
"filename": "mixin.blocks.tokens.json",
"isInline": false,
"isInline": true,
"line": 18,
"name": "input",
"selfClosing": false,
Expand Down Expand Up @@ -13660,7 +13660,7 @@ Object {
},
"column": 7,
"filename": "mixin.blocks.tokens.json",
"isInline": false,
"isInline": true,
"line": 19,
"name": "input",
"selfClosing": false,
Expand Down Expand Up @@ -18913,7 +18913,7 @@ Object {
},
"column": 3,
"filename": "text-block.tokens.json",
"isInline": false,
"isInline": true,
"line": 3,
"name": "input",
"selfClosing": false,
Expand All @@ -18924,7 +18924,7 @@ Object {
},
"column": 1,
"filename": "text-block.tokens.json",
"isInline": false,
"isInline": true,
"line": 2,
"name": "label",
"selfClosing": false,
Expand Down Expand Up @@ -18972,7 +18972,7 @@ Object {
},
"column": 3,
"filename": "text-block.tokens.json",
"isInline": false,
"isInline": true,
"line": 6,
"name": "input",
"selfClosing": false,
Expand All @@ -18983,7 +18983,7 @@ Object {
},
"column": 1,
"filename": "text-block.tokens.json",
"isInline": false,
"isInline": true,
"line": 5,
"name": "label",
"selfClosing": false,
Expand Down
12 changes: 3 additions & 9 deletions packages/pug/test/cases/attrs.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
<a href="/contact">contact</a><a class="button" href="/save">save</a><a foo="foo" bar="bar" baz="baz"></a><a foo="foo, bar, baz" bar="1"></a><a foo="((foo))" bar="1"></a>
<select>
<a href="/contact">contact</a><a class="button" href="/save">save</a><a foo="foo" bar="bar" baz="baz"></a><a foo="foo, bar, baz" bar="1"></a><a foo="((foo))" bar="1"></a><select>
<option value="foo" selected="selected">Foo</option>
<option selected="selected" value="bar">Bar</option>
</select><a foo="class:"></a>
<input pattern="\S+"/><a href="/contact">contact</a><a class="button" href="/save">save</a><a foo="foo" bar="bar" baz="baz"></a><a foo="foo, bar, baz" bar="1"></a><a foo="((foo))" bar="1"></a>
<select>
<option selected="selected" value="bar">Bar</option></select><a foo="class:"></a><input pattern="\S+"/><a href="/contact">contact</a><a class="button" href="/save">save</a><a foo="foo" bar="bar" baz="baz"></a><a foo="foo, bar, baz" bar="1"></a><a foo="((foo))" bar="1"></a><select>
<option value="foo" selected="selected">Foo</option>
<option selected="selected" value="bar">Bar</option>
</select><a foo="class:"></a>
<input pattern="\S+"/>
<option selected="selected" value="bar">Bar</option></select><a foo="class:"></a><input pattern="\S+"/>
<foo terse="true"></foo>
<foo date="1970-01-01T00:00:00.000Z"></foo>
<foo abc="abc" def="def"></foo>
Expand Down
4 changes: 1 addition & 3 deletions packages/pug/test/cases/escape-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
<head>
<title>escape-test</title>
</head>
<body>
<textarea>&lt;param name=&quot;flashvars&quot; value=&quot;a=&amp;quot;value_a&amp;quot;&amp;b=&amp;quot;value_b&amp;quot;&amp;c=3&quot;/&gt;</textarea>
</body>
<body><textarea>&lt;param name=&quot;flashvars&quot; value=&quot;a=&amp;quot;value_a&amp;quot;&amp;b=&amp;quot;value_b&amp;quot;&amp;c=3&quot;/&gt;</textarea></body>
</html>
5 changes: 1 addition & 4 deletions packages/pug/test/cases/html5.html
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
<!DOCTYPE html>
<input type="checkbox" checked>
<input type="checkbox" checked>
<input type="checkbox">
<!DOCTYPE html><input type="checkbox" checked><input type="checkbox" checked><input type="checkbox">
15 changes: 4 additions & 11 deletions packages/pug/test/cases/mixin.blocks.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
<html>
<body>
<form method="GET" action="/search">
<input type="hidden" name="_csrf" value="hey"/>
<input type="text" name="query" placeholder="Search"/>
<input type="submit" value="Search"/>
<form method="GET" action="/search"><input type="hidden" name="_csrf" value="hey"/><input type="text" name="query" placeholder="Search"/><input type="submit" value="Search"/>
</form>
</body>
</html>
<html>
<body>
<form method="POST" action="/search">
<input type="hidden" name="_csrf" value="hey"/>
<input type="text" name="query" placeholder="Search"/>
<input type="submit" value="Search"/>
<form method="POST" action="/search"><input type="hidden" name="_csrf" value="hey"/><input type="text" name="query" placeholder="Search"/><input type="submit" value="Search"/>
</form>
</body>
</html>
<html>
<body>
<form method="POST" action="/search">
<input type="hidden" name="_csrf" value="hey"/>
<form method="POST" action="/search"><input type="hidden" name="_csrf" value="hey"/>
</form>
</body>
</html>
Expand All @@ -31,4 +24,4 @@
</div>
</div>
<div id="baz">123
</div>
</div>
7 changes: 1 addition & 6 deletions packages/pug/test/cases/text-block.html
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
<label>Username:
<input type="text" name="user[name]"/>
</label>
<label>Password:
<input type="text" name="user[pass]"/>
</label>
<label>Username:<input type="text" name="user[name]"/></label><label>Password:<input type="text" name="user[pass]"/></label>