Skip to content

Commit 3488bed

Browse files
committed
only set attributes via properties when truly necessary (#1434)
1 parent 32107d8 commit 3488bed

File tree

1 file changed

+6
-170
lines changed
  • src/compiler/compile/render-dom/wrappers/Element

1 file changed

+6
-170
lines changed

src/compiler/compile/render-dom/wrappers/Element/Attribute.ts

+6-170
Original file line numberDiff line numberDiff line change
@@ -224,79 +224,19 @@ export default class AttributeWrapper {
224224
}
225225
}
226226

227-
// source: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
228227
const attribute_lookup = {
229-
accept: { applies_to: ['form', 'input'] },
230-
'accept-charset': { property_name: 'acceptCharset', applies_to: ['form'] },
231-
accesskey: { property_name: 'accessKey' },
232-
action: { applies_to: ['form'] },
233-
align: {
234-
applies_to: [
235-
'applet',
236-
'caption',
237-
'col',
238-
'colgroup',
239-
'hr',
240-
'iframe',
241-
'img',
242-
'table',
243-
'tbody',
244-
'td',
245-
'tfoot',
246-
'th',
247-
'thead',
248-
'tr',
249-
],
250-
},
251228
allowfullscreen: { property_name: 'allowFullscreen', applies_to: ['iframe'] },
252-
alt: { applies_to: ['applet', 'area', 'img', 'input'] },
229+
allowpaymentrequest: { property_name: 'allowPaymentRequest', applies_to: ['iframe'] },
253230
async: { applies_to: ['script'] },
254-
autocomplete: { applies_to: ['form', 'input'] },
255231
autofocus: { applies_to: ['button', 'input', 'keygen', 'select', 'textarea'] },
256232
autoplay: { applies_to: ['audio', 'video'] },
257-
autosave: { applies_to: ['input'] },
258-
bgcolor: {
259-
property_name: 'bgColor',
260-
applies_to: [
261-
'body',
262-
'col',
263-
'colgroup',
264-
'marquee',
265-
'table',
266-
'tbody',
267-
'tfoot',
268-
'td',
269-
'th',
270-
'tr',
271-
],
272-
},
273-
border: { applies_to: ['img', 'object', 'table'] },
274-
buffered: { applies_to: ['audio', 'video'] },
275-
challenge: { applies_to: ['keygen'] },
276-
charset: { applies_to: ['meta', 'script'] },
277233
checked: { applies_to: ['command', 'input'] },
278-
cite: { applies_to: ['blockquote', 'del', 'ins', 'q'] },
279-
class: { property_name: 'className' },
280-
code: { applies_to: ['applet'] },
281-
codebase: { property_name: 'codeBase', applies_to: ['applet'] },
282-
color: { applies_to: ['basefont', 'font', 'hr'] },
283-
cols: { applies_to: ['textarea'] },
284-
colspan: { property_name: 'colSpan', applies_to: ['td', 'th'] },
285-
content: { applies_to: ['meta'] },
286-
contenteditable: { property_name: 'contentEditable' },
287-
contextmenu: {},
288234
controls: { applies_to: ['audio', 'video'] },
289-
coords: { applies_to: ['area'] },
290-
data: { applies_to: ['object'] },
291-
datetime: { property_name: 'dateTime', applies_to: ['del', 'ins', 'time'] },
292235
default: { applies_to: ['track'] },
293236
defer: { applies_to: ['script'] },
294-
dir: {},
295-
dirname: { property_name: 'dirName', applies_to: ['input', 'textarea'] },
296237
disabled: {
297238
applies_to: [
298239
'button',
299-
'command',
300240
'fieldset',
301241
'input',
302242
'keygen',
@@ -306,119 +246,21 @@ const attribute_lookup = {
306246
'textarea',
307247
],
308248
},
309-
download: { applies_to: ['a', 'area'] },
310-
draggable: {},
311-
dropzone: {},
312-
enctype: { applies_to: ['form'] },
313-
for: { property_name: 'htmlFor', applies_to: ['label', 'output'] },
314-
formaction: { applies_to: ['input', 'button'] },
315-
headers: { applies_to: ['td', 'th'] },
316-
height: {
317-
applies_to: ['canvas', 'embed', 'iframe', 'img', 'input', 'object', 'video'],
318-
},
249+
formnovalidate: { property_name: 'formNoValidate', applies_to: ['button', 'input'] },
319250
hidden: {},
320-
high: { applies_to: ['meter'] },
321-
href: { applies_to: ['a', 'area', 'base', 'link'] },
322-
hreflang: { applies_to: ['a', 'area', 'link'] },
323-
'http-equiv': { property_name: 'httpEquiv', applies_to: ['meta'] },
324-
icon: { applies_to: ['command'] },
325-
id: {},
326251
indeterminate: { applies_to: ['input'] },
327252
ismap: { property_name: 'isMap', applies_to: ['img'] },
328-
itemprop: {},
329-
keytype: { applies_to: ['keygen'] },
330-
kind: { applies_to: ['track'] },
331-
label: { applies_to: ['track'] },
332-
lang: {},
333-
language: { applies_to: ['script'] },
334-
loop: { applies_to: ['audio', 'bgsound', 'marquee', 'video'] },
335-
low: { applies_to: ['meter'] },
336-
manifest: { applies_to: ['html'] },
337-
max: { applies_to: ['input', 'meter', 'progress'] },
338-
maxlength: { property_name: 'maxLength', applies_to: ['input', 'textarea'] },
339-
media: { applies_to: ['a', 'area', 'link', 'source', 'style'] },
340-
method: { applies_to: ['form'] },
341-
min: { applies_to: ['input', 'meter'] },
253+
loop: { applies_to: ['audio', 'bgsound', 'video'] },
342254
multiple: { applies_to: ['input', 'select'] },
343255
muted: { applies_to: ['audio', 'video'] },
344-
name: {
345-
applies_to: [
346-
'button',
347-
'form',
348-
'fieldset',
349-
'iframe',
350-
'input',
351-
'keygen',
352-
'object',
353-
'output',
354-
'select',
355-
'textarea',
356-
'map',
357-
'meta',
358-
'param',
359-
],
360-
},
256+
nomodule: { property_name: 'noModule', applies_to: ['script'] },
361257
novalidate: { property_name: 'noValidate', applies_to: ['form'] },
362-
open: { applies_to: ['details'] },
363-
optimum: { applies_to: ['meter'] },
364-
pattern: { applies_to: ['input'] },
365-
ping: { applies_to: ['a', 'area'] },
366-
placeholder: { applies_to: ['input', 'textarea'] },
367-
poster: { applies_to: ['video'] },
368-
preload: { applies_to: ['audio', 'video'] },
369-
radiogroup: { applies_to: ['command'] },
258+
open: { applies_to: ['details', 'dialog'] },
259+
playsinline: { property_name: 'playsInline', applies_to: ['video'] },
370260
readonly: { property_name: 'readOnly', applies_to: ['input', 'textarea'] },
371-
rel: { applies_to: ['a', 'area', 'link'] },
372261
required: { applies_to: ['input', 'select', 'textarea'] },
373262
reversed: { applies_to: ['ol'] },
374-
rows: { applies_to: ['textarea'] },
375-
rowspan: { property_name: 'rowSpan', applies_to: ['td', 'th'] },
376-
sandbox: { applies_to: ['iframe'] },
377-
scope: { applies_to: ['th'] },
378-
scoped: { applies_to: ['style'] },
379-
seamless: { applies_to: ['iframe'] },
380263
selected: { applies_to: ['option'] },
381-
shape: { applies_to: ['a', 'area'] },
382-
size: { applies_to: ['input', 'select'] },
383-
sizes: { applies_to: ['link', 'img', 'source'] },
384-
span: { applies_to: ['col', 'colgroup'] },
385-
spellcheck: {},
386-
src: {
387-
applies_to: [
388-
'audio',
389-
'embed',
390-
'iframe',
391-
'img',
392-
'input',
393-
'script',
394-
'source',
395-
'track',
396-
'video',
397-
],
398-
},
399-
srcdoc: { applies_to: ['iframe'] },
400-
srclang: { applies_to: ['track'] },
401-
srcset: { applies_to: ['img'] },
402-
start: { applies_to: ['ol'] },
403-
step: { applies_to: ['input'] },
404-
style: { property_name: 'style.cssText' },
405-
summary: { applies_to: ['table'] },
406-
tabindex: { property_name: 'tabIndex' },
407-
target: { applies_to: ['a', 'area', 'base', 'form'] },
408-
title: {},
409-
type: {
410-
applies_to: [
411-
'button',
412-
'command',
413-
'embed',
414-
'object',
415-
'script',
416-
'source',
417-
'style',
418-
'menu',
419-
],
420-
},
421-
usemap: { property_name: 'useMap', applies_to: ['img', 'input', 'object'] },
422264
value: {
423265
applies_to: [
424266
'button',
@@ -432,12 +274,6 @@ const attribute_lookup = {
432274
'textarea',
433275
],
434276
},
435-
volume: { applies_to: ['audio', 'video'] },
436-
playbackRate: { applies_to: ['audio', 'video'] },
437-
width: {
438-
applies_to: ['canvas', 'embed', 'iframe', 'img', 'input', 'object', 'video'],
439-
},
440-
wrap: { applies_to: ['textarea'] },
441277
};
442278

443279
Object.keys(attribute_lookup).forEach(name => {

0 commit comments

Comments
 (0)