@@ -13,28 +13,53 @@ export function repeat (character, count) {
1313}
1414
1515export var blockElements = [
16- 'address ' , 'article ' , 'aside ' , 'audio ' , 'blockquote ' , 'body ' , 'canvas ' ,
17- 'center ' , 'dd ' , 'dir ' , 'div ' , 'dl ' , 'dt ' , 'fieldset ' , 'figcaption ' ,
18- 'figure ' , 'footer ' , 'form ' , 'frameset ' , 'h1 ' , 'h2 ' , 'h3 ' , 'h4 ' , 'h5 ' , 'h6 ' ,
19- 'header ' , 'hgroup ' , 'hr ' , 'html ' , 'isindex ' , 'li ' , 'main ' , 'menu ' , 'nav ' ,
20- 'noframes ' , 'noscript ' , 'ol ' , 'output ' , 'p ' , 'pre ' , 'section ' , 'table ' ,
21- 'tbody ' , 'td ' , 'tfoot ' , 'th ' , 'thead' , 'tr' , 'ul '
16+ 'ADDRESS ' , 'ARTICLE ' , 'ASIDE ' , 'AUDIO ' , 'BLOCKQUOTE ' , 'BODY ' , 'CANVAS ' ,
17+ 'CENTER ' , 'DD ' , 'DIR ' , 'DIV ' , 'DL ' , 'DT ' , 'FIELDSET ' , 'FIGCAPTION' , 'FIGURE ',
18+ 'FOOTER ' , 'FORM ' , 'FRAMESET ' , 'H1 ' , 'H2 ' , 'H3 ' , 'H4 ' , 'H5 ' , 'H6 ' , 'HEADER ' ,
19+ 'HGROUP ' , 'HR ' , 'HTML ' , 'ISINDEX ' , 'LI ' , 'MAIN ' , 'MENU ' , 'NAV ' , 'NOFRAMES ' ,
20+ 'NOSCRIPT ' , 'OL ' , 'OUTPUT ' , 'P ' , 'PRE ' , 'SECTION ' , 'TABLE ' , 'TBODY' , 'TD ',
21+ 'TFOOT ' , 'TH ' , 'THEAD ' , 'TR ' , 'UL '
2222]
2323
2424export function isBlock ( node ) {
25- return blockElements . indexOf ( node . nodeName . toLowerCase ( ) ) !== - 1
25+ return is ( node , blockElements )
2626}
2727
2828export var voidElements = [
29- 'area ' , 'base ' , 'br ' , 'col ' , 'command ' , 'embed ' , 'hr ' , 'img ' , 'input ' ,
30- 'keygen ' , 'link ' , 'meta ' , 'param ' , 'source ' , 'track ' , 'wbr '
29+ 'AREA ' , 'BASE ' , 'BR ' , 'COL ' , 'COMMAND ' , 'EMBED ' , 'HR ' , 'IMG ' , 'INPUT ' ,
30+ 'KEYGEN ' , 'LINK ' , 'META ' , 'PARAM ' , 'SOURCE ' , 'TRACK ' , 'WBR '
3131]
3232
3333export function isVoid ( node ) {
34- return voidElements . indexOf ( node . nodeName . toLowerCase ( ) ) !== - 1
34+ return is ( node , voidElements )
3535}
3636
37- var voidSelector = voidElements . join ( )
3837export function hasVoid ( node ) {
39- return node . querySelector && node . querySelector ( voidSelector )
38+ return has ( node , voidElements )
39+ }
40+
41+ var meaningfulWhenBlankElements = [
42+ 'A' , 'TABLE' , 'THEAD' , 'TBODY' , 'TFOOT' , 'TH' , 'TD' , 'IFRAME' , 'SCRIPT' ,
43+ 'AUDIO' , 'VIDEO'
44+ ]
45+
46+ export function isMeaningfulWhenBlank ( node ) {
47+ return is ( node , meaningfulWhenBlankElements )
48+ }
49+
50+ export function hasMeaningfulWhenBlank ( node ) {
51+ return has ( node , meaningfulWhenBlankElements )
52+ }
53+
54+ function is ( node , tagNames ) {
55+ return tagNames . indexOf ( node . nodeName ) >= 0
56+ }
57+
58+ function has ( node , tagNames ) {
59+ return (
60+ node . getElementsByTagName &&
61+ tagNames . some ( function ( tagName ) {
62+ return node . getElementsByTagName ( tagName ) . length
63+ } )
64+ )
4065}
0 commit comments