You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/src/utils/quoteIfNecessary.ts

12 lines
331 B

import isValidIdentifier from './isValidIdentifier';
import reservedNames from './reservedNames';
export function quoteNameIfNecessary(name) {
if (!isValidIdentifier(name)) return `"${name}"`;
return name;
}
export function quotePropIfNecessary(name) {
if (!isValidIdentifier(name)) return `["${name}"]`;
return `.${name}`;
}