1
0
mirror of https://github.com/flarum/core.git synced 2025-08-08 09:26:34 +02:00

update Component to error if 'tag' attribute is passed - messes with mithril

This commit is contained in:
David Sevilla Martin
2020-08-12 20:39:38 -04:00
committed by Franz Liedke
parent fcda092558
commit b78db0268a

View File

@@ -66,12 +66,18 @@ export default abstract class Component<T extends ComponentAttrs = any> implemen
private setAttrs(attrs: T = {} as T) {
this.initAttrs(attrs);
if (attrs && 'children' in attrs) {
throw new Error(
`[${
(this.constructor as any).name
}] The "children" attribute of attrs should never be used. Either pass children in as the vnode children or rename the attribute`
);
if (attrs) {
if ('children' in attrs) {
throw new Error(
`[${
(this.constructor as any).name
}] The "children" attribute of attrs should never be used. Either pass children in as the vnode children or rename the attribute`
);
}
if ('tag' in attrs) {
throw new Error(`[${(this.constructor as any).name}] You cannot use the "tag" attribute name with Mithril 2.`);
}
}
this.attrs = attrs;