From 99a56f31caa964081b1a3a1d0749812d804b40cb Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 2 Aug 2023 12:36:00 -0300 Subject: html: Tag.clone, Template.clone: clone own constructors --- src/util/html.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/util/html.js b/src/util/html.js index 2468b8db..b49cce03 100644 --- a/src/util/html.js +++ b/src/util/html.js @@ -193,7 +193,11 @@ export class Tag { } clone() { - return new Tag(this.tagName, this.attributes, this.content); + return Reflect.construct(this.constructor, [ + this.tagName, + this.attributes, + this.content, + ]); } set tagName(value) { @@ -507,8 +511,12 @@ export class Template { } clone() { - const clone = new Template(this.#description); + const clone = Reflect.construct(this.constructor, [ + this.#description, + ]); + clone.setSlots(this.#slotValues); + return clone; } -- cgit 1.3.0-6-gf8a5