typed for preventing a repeat of the tragedy

pull/7944/head
Yuichiro Yamashita 4 years ago
parent f3afd76f9c
commit 87b5c2d290

@ -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'] },

@ -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<string> = new Set([..._boolean_attributes]);

Loading…
Cancel
Save