This repository has been archived by the owner on Dec 7, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 145
/
html-inspector.js
2284 lines (1989 loc) · 63.8 KB
/
html-inspector.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*!
* HTML Inspector - v0.8.2
*
* Copyright (c) 2015 Philip Walton <http://philipwalton.com>
* Released under the MIT license
*
* Date: 2015-01-30
*/
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
/**
* Get an object representation of an element's attributes
*/
function getAttributes(element) {
var map = element.attributes
, len = map.length
, i = 0
, attr
, attrs = {}
// return an empty array if there are no attributes
if (len === 0) return {}
while (attr = map[i++]) {
attrs[attr.name] = attr.value
}
return attrs
}
module.exports = getAttributes
},{}],2:[function(require,module,exports){
var toArray = require("mout/lang/toArray")
/**
* Detects the browser's native matches() implementation
* and calls that. Error if not found.
*/
function matchesSelector(element, selector) {
var i = 0
, method
, methods = [
"matches",
"matchesSelector",
"webkitMatchesSelector",
"mozMatchesSelector",
"msMatchesSelector",
"oMatchesSelector"
]
while (method = methods[i++]) {
if (typeof element[method] == "function")
return element[method](selector)
}
throw new Error("You are using a browser that doesn't not support"
+ " element.matches() or element.matchesSelector()")
}
/**
* Similar to jQuery's .is() method
* Accepts a DOM element and an object to test against
*
* The test object can be a DOM element, a string selector, an array of
* DOM elements or string selectors.
*
* Returns true if the element matches any part of the test
*/
function matches(element, test) {
// test can be null, but if it is, it never matches
if (test == null) {
return false
}
// if test is a string or DOM element convert it to an array,
else if (typeof test == "string" || test.nodeType) {
test = [test]
}
// if it has a length property call toArray in case it's array-like
else if ("length" in test) {
test = toArray(test)
}
return test.some(function(item) {
if (typeof item == "string")
return matchesSelector(element, item)
else
return element === item
})
}
module.exports = matches
},{"mout/lang/toArray":13}],3:[function(require,module,exports){
/**
* Returns an array of the element's parent elements
*/
function parents(element) {
var list = []
while (element.parentNode && element.parentNode.nodeType == 1) {
list.push(element = element.parentNode)
}
return list
}
module.exports = parents
},{}],4:[function(require,module,exports){
var makeIterator = require('../function/makeIterator_');
/**
* Array filter
*/
function filter(arr, callback, thisObj) {
callback = makeIterator(callback, thisObj);
var results = [];
if (arr == null) {
return results;
}
var i = -1, len = arr.length, value;
while (++i < len) {
value = arr[i];
if (callback(value, i, arr)) {
results.push(value);
}
}
return results;
}
module.exports = filter;
},{"../function/makeIterator_":7}],5:[function(require,module,exports){
var filter = require('./filter');
/**
* @return {array} Array of unique items
*/
function unique(arr, compare){
compare = compare || isEqual;
return filter(arr, function(item, i, arr){
var n = arr.length;
while (++i < n) {
if ( compare(item, arr[i]) ) {
return false;
}
}
return true;
});
}
function isEqual(a, b){
return a === b;
}
module.exports = unique;
},{"./filter":4}],6:[function(require,module,exports){
/**
* Returns the first argument provided to it.
*/
function identity(val){
return val;
}
module.exports = identity;
},{}],7:[function(require,module,exports){
var identity = require('./identity');
var prop = require('./prop');
var deepMatches = require('../object/deepMatches');
/**
* Converts argument into a valid iterator.
* Used internally on most array/object/collection methods that receives a
* callback/iterator providing a shortcut syntax.
*/
function makeIterator(src, thisObj){
if (src == null) {
return identity;
}
switch(typeof src) {
case 'function':
// function is the first to improve perf (most common case)
// also avoid using `Function#call` if not needed, which boosts
// perf a lot in some cases
return (typeof thisObj !== 'undefined')? function(val, i, arr){
return src.call(thisObj, val, i, arr);
} : src;
case 'object':
return function(val){
return deepMatches(val, src);
};
case 'string':
case 'number':
return prop(src);
}
}
module.exports = makeIterator;
},{"../object/deepMatches":14,"./identity":6,"./prop":8}],8:[function(require,module,exports){
/**
* Returns a function that gets a property of the passed object
*/
function prop(name){
return function(obj){
return obj[name];
};
}
module.exports = prop;
},{}],9:[function(require,module,exports){
var isKind = require('./isKind');
/**
*/
var isArray = Array.isArray || function (val) {
return isKind(val, 'Array');
};
module.exports = isArray;
},{"./isKind":10}],10:[function(require,module,exports){
var kindOf = require('./kindOf');
/**
* Check if value is from a specific "kind".
*/
function isKind(val, kind){
return kindOf(val) === kind;
}
module.exports = isKind;
},{"./kindOf":12}],11:[function(require,module,exports){
var isKind = require('./isKind');
/**
*/
function isRegExp(val) {
return isKind(val, 'RegExp');
}
module.exports = isRegExp;
},{"./isKind":10}],12:[function(require,module,exports){
var _rKind = /^\[object (.*)\]$/,
_toString = Object.prototype.toString,
UNDEF;
/**
* Gets the "kind" of value. (e.g. "String", "Number", etc)
*/
function kindOf(val) {
if (val === null) {
return 'Null';
} else if (val === UNDEF) {
return 'Undefined';
} else {
return _rKind.exec( _toString.call(val) )[1];
}
}
module.exports = kindOf;
},{}],13:[function(require,module,exports){
var kindOf = require('./kindOf');
var _win = this;
/**
* Convert array-like object into array
*/
function toArray(val){
var ret = [],
kind = kindOf(val),
n;
if (val != null) {
if ( val.length == null || kind === 'String' || kind === 'Function' || kind === 'RegExp' || val === _win ) {
//string, regexp, function have .length but user probably just want
//to wrap value into an array..
ret[ret.length] = val;
} else {
//window returns true on isObject in IE7 and may have length
//property. `typeof NodeList` returns `function` on Safari so
//we can't use it (#58)
n = val.length;
while (n--) {
ret[n] = val[n];
}
}
}
return ret;
}
module.exports = toArray;
},{"./kindOf":12}],14:[function(require,module,exports){
var forOwn = require('./forOwn');
var isArray = require('../lang/isArray');
function containsMatch(array, pattern) {
var i = -1, length = array.length;
while (++i < length) {
if (deepMatches(array[i], pattern)) {
return true;
}
}
return false;
}
function matchArray(target, pattern) {
var i = -1, patternLength = pattern.length;
while (++i < patternLength) {
if (!containsMatch(target, pattern[i])) {
return false;
}
}
return true;
}
function matchObject(target, pattern) {
var result = true;
forOwn(pattern, function(val, key) {
if (!deepMatches(target[key], val)) {
// Return false to break out of forOwn early
return (result = false);
}
});
return result;
}
/**
* Recursively check if the objects match.
*/
function deepMatches(target, pattern){
if (target && typeof target === 'object') {
if (isArray(target) && isArray(pattern)) {
return matchArray(target, pattern);
} else {
return matchObject(target, pattern);
}
} else {
return target === pattern;
}
}
module.exports = deepMatches;
},{"../lang/isArray":9,"./forOwn":16}],15:[function(require,module,exports){
var hasOwn = require('./hasOwn');
var _hasDontEnumBug,
_dontEnums;
function checkDontEnum(){
_dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
];
_hasDontEnumBug = true;
for (var key in {'toString': null}) {
_hasDontEnumBug = false;
}
}
/**
* Similar to Array/forEach but works over object properties and fixes Don't
* Enum bug on IE.
* based on: http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
*/
function forIn(obj, fn, thisObj){
var key, i = 0;
// no need to check if argument is a real object that way we can use
// it for arrays, functions, date, etc.
//post-pone check till needed
if (_hasDontEnumBug == null) checkDontEnum();
for (key in obj) {
if (exec(fn, obj, key, thisObj) === false) {
break;
}
}
if (_hasDontEnumBug) {
var ctor = obj.constructor,
isProto = !!ctor && obj === ctor.prototype;
while (key = _dontEnums[i++]) {
// For constructor, if it is a prototype object the constructor
// is always non-enumerable unless defined otherwise (and
// enumerated above). For non-prototype objects, it will have
// to be defined on this object, since it cannot be defined on
// any prototype objects.
//
// For other [[DontEnum]] properties, check if the value is
// different than Object prototype value.
if (
(key !== 'constructor' ||
(!isProto && hasOwn(obj, key))) &&
obj[key] !== Object.prototype[key]
) {
if (exec(fn, obj, key, thisObj) === false) {
break;
}
}
}
}
}
function exec(fn, obj, key, thisObj){
return fn.call(thisObj, obj[key], key, obj);
}
module.exports = forIn;
},{"./hasOwn":17}],16:[function(require,module,exports){
var hasOwn = require('./hasOwn');
var forIn = require('./forIn');
/**
* Similar to Array/forEach but works over object properties and fixes Don't
* Enum bug on IE.
* based on: http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
*/
function forOwn(obj, fn, thisObj){
forIn(obj, function(val, key){
if (hasOwn(obj, key)) {
return fn.call(thisObj, obj[key], key, obj);
}
});
}
module.exports = forOwn;
},{"./forIn":15,"./hasOwn":17}],17:[function(require,module,exports){
/**
* Safer Object.hasOwnProperty
*/
function hasOwn(obj, prop){
return Object.prototype.hasOwnProperty.call(obj, prop);
}
module.exports = hasOwn;
},{}],18:[function(require,module,exports){
var forOwn = require('./forOwn');
/**
* Combine properties from all the objects into first one.
* - This method affects target object in place, if you want to create a new Object pass an empty object as first param.
* @param {object} target Target Object
* @param {...object} objects Objects to be combined (0...n objects).
* @return {object} Target Object.
*/
function mixIn(target, objects){
var i = 0,
n = arguments.length,
obj;
while(++i < n){
obj = arguments[i];
if (obj != null) {
forOwn(obj, copyProp, target);
}
}
return target;
}
function copyProp(val, key){
this[key] = val;
}
module.exports = mixIn;
},{"./forOwn":16}],19:[function(require,module,exports){
function Callbacks() {
this.handlers = []
}
Callbacks.prototype.add = function(fn) {
this.handlers.push(fn)
}
Callbacks.prototype.remove = function(fn) {
this.handlers = this.handlers.filter(function(handler) {
return handler != fn
})
}
Callbacks.prototype.fire = function(context, args) {
this.handlers.forEach(function(handler) {
handler.apply(context, args)
})
}
module.exports = Callbacks
},{}],20:[function(require,module,exports){
var Listener = require("./listener")
, Modules = require("./modules")
, Reporter = require("./reporter")
, Rules = require("./rules")
, toArray = require("mout/lang/toArray")
, isRegExp = require("mout/lang/isRegExp")
, unique = require("mout/array/unique")
, mixIn = require("mout/object/mixIn")
, matches = require("dom-utils/src/matches")
, getAttributes = require("dom-utils/src/get-attributes")
, isCrossOrigin = require("./utils/cross-origin")
/**
* Set (or reset) all data back to its original value
* and initialize the specified rules
*/
function setup(listener, reporter, useRules, excludeRules) {
var rules = useRules == null
? Object.keys(HTMLInspector.rules)
: useRules
if (excludeRules) {
rules = rules.filter(function(rule) {
return excludeRules.indexOf(rule) < 0
})
}
rules.forEach(function(rule) {
if (HTMLInspector.rules[rule]) {
HTMLInspector.rules[rule].func.call(
HTMLInspector,
listener,
reporter,
HTMLInspector.rules[rule].config
)
}
})
}
function traverseDOM(listener, node, excludeElements, excludeSubTrees) {
// only deal with element nodes
if (node.nodeType != 1) return
var attrs = getAttributes(node)
// trigger events for this element unless it's been excluded
if (!matches(node, excludeElements)) {
listener.trigger("element", node, [node.nodeName.toLowerCase(), node])
if (node.id) {
listener.trigger("id", node, [node.id, node])
}
toArray(node.classList).forEach(function(name) {
listener.trigger("class", node, [name, node])
})
Object.keys(attrs).sort().forEach(function(name) {
listener.trigger("attribute", node, [name, attrs[name], node])
})
}
// recurse through the subtree unless it's been excluded
if (!matches(node, excludeSubTrees)) {
toArray(node.childNodes).forEach(function(node) {
traverseDOM(listener, node, excludeElements, excludeSubTrees)
})
}
}
function mergeOptions(options) {
// allow config to be individual properties of the defaults object
if (options) {
if (typeof options == "string" || options.nodeType == 1) {
options = { domRoot: options }
} else if (Array.isArray(options)) {
options = { useRules: options }
} else if (typeof options == "function") {
options = { onComplete: options }
}
}
// merge options with the defaults
options = mixIn({}, HTMLInspector.defaults, options)
// set the domRoot to an HTMLElement if it's not
options.domRoot = typeof options.domRoot == "string"
? document.querySelector(options.domRoot)
: options.domRoot
return options
}
/**
* cross-origin iframe elements throw errors when being
* logged to the console.
* This function removes them from the context before
* logging them to the console.
*/
function filterCrossOrigin(elements) {
// convert elements to an array if it's not already
if (!Array.isArray(elements)) elements = [elements]
elements = elements.map(function(el) {
if (el
&& el.nodeName
&& el.nodeName.toLowerCase() == "iframe"
&& isCrossOrigin(el.src)
)
return "(can't display iframe with cross-origin source: " + el.src + ")"
else
return el
})
return elements.length === 1 ? elements[0] : elements
}
var HTMLInspector = {
defaults: {
domRoot: "html",
useRules: null,
excludeRules: null,
excludeElements: "svg",
excludeSubTrees: ["svg", "iframe"],
onComplete: function(errors) {
errors.forEach(function(error) {
console.warn(error.message, filterCrossOrigin(error.context))
})
}
},
rules: new Rules(),
modules: new Modules(),
inspect: function(options) {
var config = mergeOptions(options)
, listener = new Listener()
, reporter = new Reporter()
setup(listener, reporter, config.useRules, config.excludeRules)
listener.trigger("beforeInspect", config.domRoot)
traverseDOM(listener, config.domRoot, config.excludeElements, config.excludeSubTrees)
listener.trigger("afterInspect", config.domRoot)
config.onComplete(reporter.getWarnings())
}
}
HTMLInspector.modules.add( require("./modules/css.js") )
HTMLInspector.modules.add( require("./modules/validation.js") )
HTMLInspector.rules.add( require("./rules/best-practices/inline-event-handlers.js") )
HTMLInspector.rules.add( require("./rules/best-practices/script-placement.js") )
HTMLInspector.rules.add( require("./rules/best-practices/unnecessary-elements.js") )
HTMLInspector.rules.add( require("./rules/best-practices/unused-classes.js") )
HTMLInspector.rules.add( require("./rules/convention/bem-conventions.js") )
HTMLInspector.rules.add( require("./rules/validation/duplicate-ids.js") )
HTMLInspector.rules.add( require("./rules/validation/unique-elements.js") )
HTMLInspector.rules.add( require("./rules/validation/validate-attributes.js") )
HTMLInspector.rules.add( require("./rules/validation/validate-element-location.js") )
HTMLInspector.rules.add( require("./rules/validation/validate-elements.js") )
window.HTMLInspector = HTMLInspector
},{"./listener":21,"./modules":22,"./modules/css.js":23,"./modules/validation.js":24,"./reporter":25,"./rules":26,"./rules/best-practices/inline-event-handlers.js":27,"./rules/best-practices/script-placement.js":28,"./rules/best-practices/unnecessary-elements.js":29,"./rules/best-practices/unused-classes.js":30,"./rules/convention/bem-conventions.js":31,"./rules/validation/duplicate-ids.js":32,"./rules/validation/unique-elements.js":33,"./rules/validation/validate-attributes.js":34,"./rules/validation/validate-element-location.js":35,"./rules/validation/validate-elements.js":36,"./utils/cross-origin":37,"dom-utils/src/get-attributes":1,"dom-utils/src/matches":2,"mout/array/unique":5,"mout/lang/isRegExp":11,"mout/lang/toArray":13,"mout/object/mixIn":18}],21:[function(require,module,exports){
var Callbacks = require("./callbacks")
function Listener() {
this._events = {}
}
Listener.prototype.on = function(event, fn) {
this._events[event] || (this._events[event] = new Callbacks())
this._events[event].add(fn)
}
Listener.prototype.off = function(event, fn) {
this._events[event] && this._events[event].remove(fn)
}
Listener.prototype.trigger = function(event, context, args) {
this._events[event] && this._events[event].fire(context, args)
}
module.exports = Listener
},{"./callbacks":19}],22:[function(require,module,exports){
var mixIn = require("mout/object/mixIn")
function Modules() {}
Modules.prototype.add = function(obj) {
this[obj.name] = obj.module
}
Modules.prototype.extend = function(name, options) {
if (typeof options == "function")
options = options.call(this[name], this[name])
mixIn(this[name], options)
}
module.exports = Modules
},{"mout/object/mixIn":18}],23:[function(require,module,exports){
var reClassSelector = /\.[a-z0-9_\-]+/ig
, toArray = require("mout/lang/toArray")
, unique = require("mout/array/unique")
, matches = require("dom-utils/src/matches")
, isCrossOrigin = require("../utils/cross-origin")
/**
* Get an array of class selectors from a CSSRuleList object
*/
function getClassesFromRuleList(rulelist) {
return rulelist.reduce(function(classes, rule) {
var matches
if (rule.styleSheet) { // from @import rules
return classes.concat(getClassesFromStyleSheets([rule.styleSheet]))
}
else if (rule.cssRules) { // from @media rules (or other conditionals)
return classes.concat(getClassesFromRuleList(toArray(rule.cssRules)))
}
else if (rule.selectorText) {
matches = rule.selectorText.match(reClassSelector) || []
return classes.concat(matches.map(function(cls) { return cls.slice(1) } ))
}
return classes
}, [])
}
/**
* Get an array of class selectors from a CSSSytleSheetList object
*/
function getClassesFromStyleSheets(styleSheets) {
return styleSheets.reduce(function(classes, sheet) {
// cross origin stylesheets don't expose their cssRules property
return sheet.href && isCrossOrigin(sheet.href)
? classes
: classes.concat(getClassesFromRuleList(toArray(sheet.cssRules)))
}, [])
}
function getStyleSheets() {
return toArray(document.styleSheets).filter(function(sheet) {
return matches(sheet.ownerNode, css.styleSheets)
})
}
var css = {
getClassSelectors: function() {
return unique(getClassesFromStyleSheets(getStyleSheets()))
},
// getSelectors: function() {
// return []
// },
styleSheets: 'link[rel="stylesheet"], style'
}
module.exports = {
name: "css",
module: css
}
},{"../utils/cross-origin":37,"dom-utils/src/matches":2,"mout/array/unique":5,"mout/lang/toArray":13}],24:[function(require,module,exports){
var foundIn = require("../utils/string-matcher")
// ============================================================
// A data map of all valid HTML elements, their attributes
// and what type of children they may contain
//
// http://drafts.htmlwg.org/html/master/iana.html#index
// ============================================================
var elementData = {
"a": {
children: "transparent*",
attributes: "globals; href; target; download; rel; hreflang; type"
},
"abbr": {
children: "phrasing",
attributes: "globals"
},
"address": {
children: "flow*",
attributes: "globals"
},
"area": {
children: "empty",
attributes: "globals; alt; coords; shape; href; target; download; rel; hreflang; type"
},
"article": {
children: "flow",
attributes: "globals"
},
"aside": {
children: "flow",
attributes: "globals"
},
"audio": {
children: "source*; transparent*",
attributes: "globals; src; crossorigin; preload; autoplay; mediagroup; loop; muted; controls"
},
"b": {
children: "phrasing",
attributes: "globals"
},
"base": {
children: "empty",
attributes: "globals; href; target"
},
"bdi": {
children: "phrasing",
attributes: "globals"
},
"bdo": {
children: "phrasing",
attributes: "globals"
},
"blockquote": {
children: "flow",
attributes: "globals; cite"
},
"body": {
children: "flow",
attributes: "globals; onafterprint; onbeforeprint; onbeforeunload; onfullscreenchange; onfullscreenerror; onhashchange; onmessage; onoffline; ononline; onpagehide; onpageshow; onpopstate; onresize; onstorage; onunload"
},
"br": {
children: "empty",
attributes: "globals"
},
"button": {
children: "phrasing*",
attributes: "globals; autofocus; disabled; form; formaction; formenctype; formmethod; formnovalidate; formtarget; name; type; value"
},
"canvas": {
children: "transparent",
attributes: "globals; width; height"
},
"caption": {
children: "flow*",
attributes: "globals"
},
"cite": {
children: "phrasing",
attributes: "globals"
},
"code": {
children: "phrasing",
attributes: "globals"
},
"col": {
children: "empty",
attributes: "globals; span"
},
"colgroup": {
children: "col",
attributes: "globals; span"
},
"menuitem": {
children: "empty",
attributes: "globals; type; label; icon; disabled; checked; radiogroup; command"
},
"data": {
children: "phrasing",
attributes: "globals; value"
},
"datalist": {
children: "phrasing; option",
attributes: "globals"
},
"dd": {
children: "flow",
attributes: "globals"
},
"del": {
children: "transparent",
attributes: "globals; cite; datetime"
},
"details": {
children: "summary*; flow",
attributes: "globals; open"
},
"dfn": {
children: "phrasing*",
attributes: "globals"
},
"dialog": {
children: "flow",
attributes: "globals; open"
},
"div": {
children: "flow",
attributes: "globals"
},
"dl": {
children: "dt*; dd*",
attributes: "globals"
},
"dt": {
children: "flow*",
attributes: "globals"
},
"em": {
children: "phrasing",
attributes: "globals"
},
"embed": {
children: "empty",
attributes: "globals; src; type; width; height; any*"
},
"fieldset": {
children: "legend*; flow",
attributes: "globals; disabled; form; name"
},
"figcaption": {
children: "flow",
attributes: "globals"
},
"figure": {
children: "figcaption*; flow",
attributes: "globals"
},
"footer": {
children: "flow*",
attributes: "globals"
},
"form": {
children: "flow*",
attributes: "globals; accept-charset; action; autocomplete; enctype; method; name; novalidate; target"
},
"h1": {
children: "phrasing",
attributes: "globals"
},
"h2": {
children: "phrasing",
attributes: "globals"
},
"h3": {
children: "phrasing",
attributes: "globals"
},
"h4": {
children: "phrasing",
attributes: "globals"
},
"h5": {
children: "phrasing",
attributes: "globals"
},
"h6": {
children: "phrasing",
attributes: "globals"
},
"head": {
children: "metadata content*",
attributes: "globals"
},
"header": {
children: "flow*",
attributes: "globals"
},
"hr": {