Skip to content

Commit 1943f19

Browse files
author
Blair Mitchelmore
committed
Adding a bunch of default attribute values and boolean attributes.
1 parent aeba523 commit 1943f19

File tree

1 file changed

+100
-4
lines changed

1 file changed

+100
-4
lines changed

page_renderer.js

Lines changed: 100 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,94 @@ var PageRenderer = function(minified) {
33
};
44

55
PageRenderer.prototype = {
6-
booleans: { // incomplete list, obviously
6+
booleans: { // complete list, as far as I know
77
'style': {
88
'scoped': true
9+
},
10+
'script': {
11+
'async': true,
12+
'defer': true
13+
},
14+
'ol': {
15+
'reversed': true
16+
},
17+
'time': {
18+
'pubdate': true
19+
},
20+
'img': {
21+
'ismap': true
22+
},
23+
'iframe': {
24+
'seamless': true
25+
},
26+
'video': {
27+
'controls': true,
28+
'loop': true,
29+
'autoplay': true
30+
},
31+
'audio': {
32+
'controls': true,
33+
'loop': true,
34+
'autoplay': true
35+
},
36+
'track': {
37+
'default': true
38+
},
39+
'form': {
40+
'novalidate': true
41+
},
42+
'fieldset': {
43+
'disabled': true
44+
},
45+
'input': {
46+
'autofocus': true,
47+
'checked': true,
48+
'disabled': true,
49+
'formnovalidate': true,
50+
'multiple': true,
51+
'readonly': true,
52+
'required': true
53+
},
54+
'button': {
55+
'autofocus': true,
56+
'disabled': true,
57+
'formnovalidate': true
58+
},
59+
'select': {
60+
'autofocus': true,
61+
'disabled': true,
62+
'multiple': true,
63+
'required': true
64+
},
65+
'optgroup': {
66+
'disabled': true
67+
},
68+
'option': {
69+
'disabled': true,
70+
'selected': true
71+
},
72+
'textarea': {
73+
'autofocus': true,
74+
'disabled': true,
75+
'readonly': true,
76+
'required': true
77+
},
78+
'keygen': {
79+
'autofocus': true,
80+
'disabled': true
81+
},
82+
'details': {
83+
'open': true
84+
},
85+
'command': {
86+
'checked': true,
87+
'disabled': true
988
}
1089
},
1190
boolean: function (element, attribute) {
1291
return !!((this.booleans[element.tag] || {})[attribute]);
1392
},
14-
blanks: { // complete list
93+
blanks: { // complete list based on <http://dev.w3.org/html5/markup/syntax.html#syntax-elements>
1594
area: true,
1695
base: true,
1796
br: true,
@@ -32,10 +111,26 @@ PageRenderer.prototype = {
32111
blank: function (element) {
33112
return this.blanks[element.tag];
34113
},
35-
defaults: { // incomplete list, obviously
114+
defaults: { // incomplete list, as far I know
36115
'style': {
37116
'type': 'text/css',
38117
'media': 'all'
118+
},
119+
'bdi': {
120+
'dir': 'auto'
121+
},
122+
'input': {
123+
'type': 'text',
124+
'autocomplete': 'default'
125+
},
126+
'button': {
127+
'type': 'submit'
128+
},
129+
'textarea': {
130+
'wrap': 'soft'
131+
},
132+
'menu': {
133+
'type': 'list'
39134
}
40135
},
41136
defaulted: function(element, attribute, value) {
@@ -110,4 +205,5 @@ PageRenderer.prototype = {
110205

111206
exports.render = function(page, minified) {
112207
return new PageRenderer(minified).render(page);
113-
};
208+
};
209+
exports.Renderer = PageRenderer;

0 commit comments

Comments
 (0)