调整传参

pull/1/head
yutent 2023-03-16 23:42:04 +08:00
parent a6efaaabf0
commit 195f3b1828
1 changed files with 7 additions and 7 deletions

View File

@ -142,7 +142,7 @@ class Template {
let partCount = strings.length - 1 let partCount = strings.length - 1
let parts = this.parts let parts = this.parts
let [html2, attrNames] = getTemplateHtml(strings, type) let [html2, attrNames] = getTemplateHtml(strings, type)
this.el = Template.createElement(html2, options) this.el = Template.createElement(html2)
walker.currentNode = this.el.content walker.currentNode = this.el.content
if (type === SVG_RESULT) { if (type === SVG_RESULT) {
let content = this.el.content let content = this.el.content
@ -220,7 +220,7 @@ class Template {
nodeIndex++ nodeIndex++
} }
} }
static createElement(html2, _options) { static createElement(html2) {
let el = document.createElement('template') let el = document.createElement('template')
el.innerHTML = html2 el.innerHTML = html2
return el return el
@ -424,8 +424,7 @@ class ChildPart {
let template = let template =
typeof type === 'number' typeof type === 'number'
? this._$getTemplate(result) ? this._$getTemplate(result)
: (type.el === void 0 && : (type.el === void 0 && (type.el = Template.createElement(type.h)),
(type.el = Template.createElement(type.h, this.options)),
type) type)
if (this._$committedValue?._$template === template) { if (this._$committedValue?._$template === template) {
@ -443,7 +442,8 @@ class ChildPart {
_$getTemplate(result) { _$getTemplate(result) {
let template = templateCache.get(result.strings) let template = templateCache.get(result.strings)
if (template === void 0) { 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 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] let part = container[WC_PART]
if (part === void 0) { if (part === void 0) {
@ -651,7 +651,7 @@ export function render(value, container, options) {
container.insertBefore(createMarker(), null), container.insertBefore(createMarker(), null),
null, null,
void 0, void 0,
options !== null && options !== void 0 ? options : {} options
) )
} }
part._$setValue(value) part._$setValue(value)