parent
8cebdd1994
commit
d0af1270dc
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@bd/core",
|
"name": "@bd/core",
|
||||||
"version": "1.5.0",
|
"version": "1.5.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "百搭UI组件库的核心",
|
"description": "百搭UI组件库的核心",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|
15
src/html.js
15
src/html.js
|
@ -134,7 +134,7 @@ function getTemplateHtml(strings, type) {
|
||||||
return [htmlResult, attrNames]
|
return [htmlResult, attrNames]
|
||||||
}
|
}
|
||||||
class Template {
|
class Template {
|
||||||
constructor({ strings, values, ['__dom_type__']: type }, options) {
|
constructor({ strings, ['__dom_type__']: type }, options) {
|
||||||
this.parts = []
|
this.parts = []
|
||||||
let node
|
let node
|
||||||
let nodeIndex = 0
|
let nodeIndex = 0
|
||||||
|
@ -157,12 +157,6 @@ class Template {
|
||||||
let attrsToRemove = []
|
let attrsToRemove = []
|
||||||
|
|
||||||
for (let name of node.getAttributeNames()) {
|
for (let name of node.getAttributeNames()) {
|
||||||
if (name === 'ref') {
|
|
||||||
options.host.$refs[node.getAttribute('ref')] = node
|
|
||||||
node.removeAttribute('ref')
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
name.endsWith(boundAttributeSuffix) ||
|
name.endsWith(boundAttributeSuffix) ||
|
||||||
name.startsWith(marker)
|
name.startsWith(marker)
|
||||||
|
@ -324,6 +318,11 @@ class TemplateInstance {
|
||||||
} else if (templatePart.type === ELEMENT_PART) {
|
} else if (templatePart.type === ELEMENT_PART) {
|
||||||
part = new ElementPart(node, this, options)
|
part = new ElementPart(node, this, options)
|
||||||
}
|
}
|
||||||
|
if (node.nodeType === 1 && node.getAttribute('ref')) {
|
||||||
|
if (options.host.$refs) {
|
||||||
|
options.host.$refs[node.getAttribute('ref')] = node
|
||||||
|
}
|
||||||
|
}
|
||||||
this._parts.push(part)
|
this._parts.push(part)
|
||||||
templatePart = parts[++partIndex]
|
templatePart = parts[++partIndex]
|
||||||
}
|
}
|
||||||
|
@ -669,6 +668,8 @@ export function render(value, container, options = {}) {
|
||||||
}
|
}
|
||||||
part._$setValue(value)
|
part._$setValue(value)
|
||||||
|
|
||||||
|
// console.log(container, options.host, options.host.$refs)
|
||||||
|
|
||||||
return part
|
return part
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,7 @@ export class Component extends HTMLElement {
|
||||||
value: Object.create(null),
|
value: Object.create(null),
|
||||||
enumerable: false
|
enumerable: false
|
||||||
})
|
})
|
||||||
|
|
||||||
this.created()
|
this.created()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue