registerCustomElement method
void
registerCustomElement(
- Element element,
- CodeBuffer buffer,
- SymbolTable scope,
- bool html5,
)
Implementation
void registerCustomElement(
Element element, CodeBuffer buffer, SymbolTable scope, bool html5) {
if (element is! RegularElement) {
throw JaelError(JaelErrorSeverity.error,
'Custom elements cannot be self-closing.', element.span);
}
var name = element.getAttribute('name')?.value?.compute(scope)?.toString();
if (name == null) {
throw JaelError(
JaelErrorSeverity.error,
"Attribute 'name' is required when registering a custom element.",
element.tagName.span);
}
try {
var p = scope.isRoot ? scope : scope.parent!;
p.create(customElementName(name), value: element, constant: true);
} on StateError {
throw JaelError(
JaelErrorSeverity.error,
"Cannot re-define element '$name' in this scope.",
element.getAttribute('name')!.span);
}
}