parent
							
								
									58d4277964
								
							
						
					
					
						commit
						0eecaa22dc
					
				| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
{
 | 
			
		||||
  "name": "@bd/core",
 | 
			
		||||
  "version": "1.5.3",
 | 
			
		||||
  "version": "1.5.4",
 | 
			
		||||
  "type": "module",
 | 
			
		||||
  "description": "百搭UI组件库的核心",
 | 
			
		||||
  "main": "dist/index.js",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										76
									
								
								src/html.js
								
								
								
								
							
							
						
						
									
										76
									
								
								src/html.js
								
								
								
								
							| 
						 | 
				
			
			@ -301,42 +301,51 @@ class TemplateInstance {
 | 
			
		|||
    let nodeIndex = 0
 | 
			
		||||
    let partIndex = 0
 | 
			
		||||
    let templatePart = parts[0]
 | 
			
		||||
 | 
			
		||||
    while (templatePart !== void 0) {
 | 
			
		||||
      if (nodeIndex === templatePart.index) {
 | 
			
		||||
        let part
 | 
			
		||||
        if (templatePart.type === CHILD_PART) {
 | 
			
		||||
          part = new ChildPart(node, node.nextSibling, this, options)
 | 
			
		||||
        } else if (templatePart.type === ATTRIBUTE_PART) {
 | 
			
		||||
          part = new templatePart.ctor(
 | 
			
		||||
            node,
 | 
			
		||||
            templatePart.name,
 | 
			
		||||
            templatePart.strings,
 | 
			
		||||
            this,
 | 
			
		||||
            options
 | 
			
		||||
          )
 | 
			
		||||
        } else if (templatePart.type === ELEMENT_PART) {
 | 
			
		||||
          part = new ElementPart(node, this, options)
 | 
			
		||||
        }
 | 
			
		||||
        // console.log(node)
 | 
			
		||||
    // 没有动态绑定时, 查一遍是否有ref属性
 | 
			
		||||
    if (templatePart === void 0) {
 | 
			
		||||
      do {
 | 
			
		||||
        if (node.nodeType === 1 && node.getAttribute('ref')) {
 | 
			
		||||
          if (options.host.$refs) {
 | 
			
		||||
            options.host.$refs[node.getAttribute('ref')] = node
 | 
			
		||||
          }
 | 
			
		||||
          options.host.$refs[node.getAttribute('ref')] = node
 | 
			
		||||
          node.removeAttribute('ref')
 | 
			
		||||
        }
 | 
			
		||||
      } while ((node = walker.nextNode()) !== null)
 | 
			
		||||
    } else {
 | 
			
		||||
      while (templatePart !== void 0) {
 | 
			
		||||
        if (nodeIndex === templatePart.index) {
 | 
			
		||||
          let part
 | 
			
		||||
          if (templatePart.type === CHILD_PART) {
 | 
			
		||||
            part = new ChildPart(node, node.nextSibling, this, options)
 | 
			
		||||
          } else if (templatePart.type === ATTRIBUTE_PART) {
 | 
			
		||||
            part = new templatePart.ctor(
 | 
			
		||||
              node,
 | 
			
		||||
              templatePart.name,
 | 
			
		||||
              templatePart.strings,
 | 
			
		||||
              this,
 | 
			
		||||
              options
 | 
			
		||||
            )
 | 
			
		||||
          } else if (templatePart.type === ELEMENT_PART) {
 | 
			
		||||
            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)
 | 
			
		||||
          templatePart = parts[++partIndex]
 | 
			
		||||
        }
 | 
			
		||||
        if (
 | 
			
		||||
          nodeIndex !==
 | 
			
		||||
          (templatePart === null || templatePart === void 0
 | 
			
		||||
            ? void 0
 | 
			
		||||
            : templatePart.index)
 | 
			
		||||
        ) {
 | 
			
		||||
          node = walker.nextNode()
 | 
			
		||||
          nodeIndex++
 | 
			
		||||
        }
 | 
			
		||||
        this._parts.push(part)
 | 
			
		||||
        templatePart = parts[++partIndex]
 | 
			
		||||
      }
 | 
			
		||||
      if (
 | 
			
		||||
        nodeIndex !==
 | 
			
		||||
        (templatePart === null || templatePart === void 0
 | 
			
		||||
          ? void 0
 | 
			
		||||
          : templatePart.index)
 | 
			
		||||
      ) {
 | 
			
		||||
        node = walker.nextNode()
 | 
			
		||||
        nodeIndex++
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return fragment
 | 
			
		||||
  }
 | 
			
		||||
  _update(values) {
 | 
			
		||||
| 
						 | 
				
			
			@ -410,7 +419,6 @@ class ChildPart {
 | 
			
		|||
  _commitNode(value) {
 | 
			
		||||
    if (this._$committedValue !== value) {
 | 
			
		||||
      this.#clear()
 | 
			
		||||
 | 
			
		||||
      this._$committedValue = this._insert(value)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -669,8 +677,6 @@ export function render(value, container, options = {}) {
 | 
			
		|||
  }
 | 
			
		||||
  part._$setValue(value)
 | 
			
		||||
 | 
			
		||||
  // console.log(container, options.host, options.host.$refs)
 | 
			
		||||
 | 
			
		||||
  return part
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue