element-vir
Version:
Heroic. Reactive. Declarative. Type safe. Web components without compromise.
17 lines (16 loc) • 576 B
JavaScript
/**
* Asserts that all the given CSS properties for the given element are valid.
*
* @category Internal
*/
export function assertValidCssProperties(elementTagName, cssProperties) {
const requiredCssPropKeyStart = [
elementTagName,
'-',
].join('');
Object.keys(cssProperties).forEach((cssPropName) => {
if (!cssPropName.startsWith(requiredCssPropKeyStart)) {
throw new Error(`Invalid CSS property name '${cssPropName}' in '${elementTagName}': CSS property names must begin with the element's tag name.`);
}
});
}