From 195f3b18283377c937215d0378c9dc1a4020ff35 Mon Sep 17 00:00:00 2001 From: yutent Date: Thu, 16 Mar 2023 23:42:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BC=A0=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/html.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/html.js b/src/html.js index 45ed0a9..4a010c0 100644 --- a/src/html.js +++ b/src/html.js @@ -142,7 +142,7 @@ class Template { let partCount = strings.length - 1 let parts = this.parts let [html2, attrNames] = getTemplateHtml(strings, type) - this.el = Template.createElement(html2, options) + this.el = Template.createElement(html2) walker.currentNode = this.el.content if (type === SVG_RESULT) { let content = this.el.content @@ -220,7 +220,7 @@ class Template { nodeIndex++ } } - static createElement(html2, _options) { + static createElement(html2) { let el = document.createElement('template') el.innerHTML = html2 return el @@ -424,8 +424,7 @@ class ChildPart { let template = typeof type === 'number' ? this._$getTemplate(result) - : (type.el === void 0 && - (type.el = Template.createElement(type.h, this.options)), + : (type.el === void 0 && (type.el = Template.createElement(type.h)), type) if (this._$committedValue?._$template === template) { @@ -443,7 +442,8 @@ class ChildPart { _$getTemplate(result) { let template = templateCache.get(result.strings) if (template === void 0) { - templateCache.set(result.strings, (template = new Template(result))) + template = new Template(result, this.options) + templateCache.set(result.strings, template) } return template } @@ -643,7 +643,7 @@ class ElementPart { } } -export function render(value, container, options) { +export function render(value, container, options = {}) { let part = container[WC_PART] if (part === void 0) { @@ -651,7 +651,7 @@ export function render(value, container, options) { container.insertBefore(createMarker(), null), null, void 0, - options !== null && options !== void 0 ? options : {} + options ) } part._$setValue(value)