Browse Source

Perf: optimized html block names lookup

pull/14/head
Vitaly Puzrin 10 years ago
parent
commit
190a8563ab
  1. 8
      lib/common/html_blocks.js
  2. 2
      lib/rules_block/htmlblock.js

8
lib/common/html_blocks.js

@ -3,8 +3,9 @@
'use strict';
var html_blocks = {};
module.exports = [
[
'article',
'aside',
'button',
@ -55,4 +56,7 @@ module.exports = [
'thead',
'ul',
'video'
];
].forEach(function (name) { html_blocks[name] = true; });
module.exports = html_blocks;

2
lib/rules_block/htmlblock.js

@ -48,7 +48,7 @@ module.exports = function htmlblock(state, startLine, endLine, silent) {
if (!match) { return false; }
}
// Make sure tag name is valid
if (block_names.indexOf(match[1].toLowerCase()) < 0) { return false; }
if (block_names[match[1].toLowerCase()] !== true) { return false; }
if (silent) { return true; }
} else {

Loading…
Cancel
Save