[IMP] runtime: do not check template equality outside dev mode

When defining a template with a name that the template set already
contains, we currently always check whether the template is the same and
throw an error when it's not. This is potentially expensive as it can
involve serializing a pretty large XML document. This check is only
supposed to help during development so this commit disables this check
outside dev mode.
This commit is contained in:
Samuel Degueldre
2023-08-25 09:03:39 +02:00
committed by Bruno Boi
parent 610ed02373
commit c78e070636
2 changed files with 13 additions and 2 deletions
+4
View File
@@ -66,6 +66,10 @@ export class TemplateSet {
addTemplate(name: string, template: string | Element) {
if (name in this.rawTemplates) {
// this check can be expensive, just silently ignore double definitions outside dev mode
if (!this.dev) {
return;
}
const rawTemplate = this.rawTemplates[name];
const currentAsString =
typeof rawTemplate === "string"