diff --git a/src/compiler/compile/render_dom/wrappers/Element/Attribute.ts b/src/compiler/compile/render_dom/wrappers/Element/Attribute.ts index 0b23d025c9..ca35ea84db 100644 --- a/src/compiler/compile/render_dom/wrappers/Element/Attribute.ts +++ b/src/compiler/compile/render_dom/wrappers/Element/Attribute.ts @@ -9,7 +9,7 @@ import Text from '../../../nodes/Text'; import handle_select_value_binding from './handle_select_value_binding'; import { Identifier, Node } from 'estree'; import { namespaces } from '../../../../utils/namespaces'; -import { boolean_attributes } from '../../../../../shared/boolean_attributes'; +import { BooleanAttributes, boolean_attributes } from '../../../../../shared/boolean_attributes'; import { regex_double_quotes } from '../../../../utils/patterns'; const non_textlike_input_types = new Set([ @@ -324,7 +324,8 @@ export default class AttributeWrapper extends BaseAttributeWrapper { } // source: https://html.spec.whatwg.org/multipage/indices.html -const attribute_lookup = { +type AttributeMetadata = { property_name?: string, applies_to?: string[] }; +const attribute_lookup: { [key in BooleanAttributes]: AttributeMetadata } & { [key in string]: AttributeMetadata } = { allowfullscreen: { property_name: 'allowFullscreen', applies_to: ['iframe'] }, allowpaymentrequest: { property_name: 'allowPaymentRequest', applies_to: ['iframe'] }, async: { applies_to: ['script'] }, @@ -351,6 +352,7 @@ const attribute_lookup = { indeterminate: { applies_to: ['input'] }, inert: {}, ismap: { property_name: 'isMap', applies_to: ['img'] }, + itemscope: {}, loop: { applies_to: ['audio', 'bgsound', 'video'] }, multiple: { applies_to: ['input', 'select'] }, muted: { applies_to: ['audio', 'video'] }, diff --git a/src/shared/boolean_attributes.ts b/src/shared/boolean_attributes.ts index e29f921e32..f6ec25c6e5 100644 --- a/src/shared/boolean_attributes.ts +++ b/src/shared/boolean_attributes.ts @@ -1,5 +1,5 @@ // source: https://html.spec.whatwg.org/multipage/indices.html -export const boolean_attributes = new Set([ +const _boolean_attributes = [ 'allowfullscreen', 'allowpaymentrequest', 'async', @@ -12,6 +12,7 @@ export const boolean_attributes = new Set([ 'disabled', 'formnovalidate', 'hidden', + 'indeterminate', 'inert', 'ismap', 'itemscope', @@ -26,4 +27,7 @@ export const boolean_attributes = new Set([ 'required', 'reversed', 'selected' -]); +] as const; + +export type BooleanAttributes = typeof _boolean_attributes[number]; +export const boolean_attributes: Set = new Set([..._boolean_attributes]);