j-component 1.4.8 → 1.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "j-component",
3
- "version": "1.4.8",
3
+ "version": "1.4.9",
4
4
  "description": "miniprogram custom component framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -128,6 +128,15 @@ class ComponentManager {
128
128
  const exparserNodes = this.shadowRoot.querySelectorAll(selector)
129
129
  return exparserNodes.map(item => getSelectComponentResult(item))
130
130
  }
131
+ caller.selectOwnerComponent = () => {
132
+ const ownerShadowRoot = this.ownerShadowRoot
133
+ if (!(ownerShadowRoot instanceof exparser.ShadowRoot)) return null
134
+
135
+ const exparserNode = ownerShadowRoot.getHostNode()
136
+ if (!exparserNode) return null
137
+
138
+ return getSelectComponentResult(exparserNode)
139
+ }
131
140
  caller.createSelectorQuery = () => new SelectorQuery(caller)
132
141
  caller.createIntersectionObserver = options => new IntersectionObserver(caller, options)
133
142
  caller.setData = (data, callback) => {
@@ -60,10 +60,10 @@ function exparserTreeToJSON(node) {
60
60
  let children = array
61
61
  const vt = node._vt
62
62
 
63
- if (vt) {
64
- if (vt.type === CONSTANT.TYPE_TEXT) {
65
- array.push(vt.content)
66
- } else if (vt.type === CONSTANT.TYPE_NATIVE || vt.type === CONSTANT.TYPE_COMPONENT) {
63
+ if (node instanceof exparser.TextNode) {
64
+ array.push(node.textContent)
65
+ } else if (node instanceof exparser.Element) {
66
+ if (!node.__virtual) {
67
67
  children = []
68
68
  const child = {
69
69
  tagName: _.getTagName(vt.componentId || vt.tagName) || vt.tagName,
@@ -78,10 +78,9 @@ function exparserTreeToJSON(node) {
78
78
  })
79
79
  array.push(child)
80
80
  }
81
+ ;(node.__wxSlotChildren || []).forEach(child => _inner(child, children))
81
82
  }
82
83
 
83
- (node.__wxSlotChildren || []).forEach(child => _inner(child, children))
84
-
85
84
  return array
86
85
  }
87
86