j-component 1.4.2 → 1.4.6

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.2",
3
+ "version": "1.4.6",
4
4
  "description": "miniprogram custom component framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -42,11 +42,11 @@ class ComponentManager {
42
42
  // 支持内置 behavior
43
43
  if (item === 'wx://component-export') {
44
44
  return global.wxComponentExport
45
- }
46
- if (item === 'wx://form-field') {
45
+ } else if (item === 'wx://form-field') {
47
46
  return global.wxFormField
48
- }
49
- if (item === 'wx://form-field-button') {
47
+ } else if (item === 'wx://form-field-group') {
48
+ return global.wxFormFieldGroup
49
+ } else if (item === 'wx://form-field-button') {
50
50
  return global.wxFormFieldButton
51
51
  }
52
52
 
package/src/index.js CHANGED
@@ -54,6 +54,10 @@ global.wxFormField = module.exports.behavior({
54
54
  }
55
55
  })
56
56
 
57
+ global.wxFormFieldGroup = module.exports.behavior({
58
+ is: 'wx://form-field-group',
59
+ })
60
+
57
61
  global.wxFormFieldButton = module.exports.behavior({
58
62
  is: 'wx://form-field-button',
59
63
  listeners: {
@@ -280,7 +280,7 @@ class RootComponent extends Component {
280
280
  }
281
281
 
282
282
  get dom() {
283
- return this._exparserNode.$$
283
+ return _.getDom(this._exparserNode)
284
284
  }
285
285
 
286
286
  /**
@@ -204,7 +204,7 @@ class VirtualNode {
204
204
  if (this.children && this.children.length) {
205
205
  if (this.type === CONSTANT.TYPE_FOR) {
206
206
  // 检查 for 语句
207
- const list = expr.calcExpression(statement.for, data)
207
+ const list = expr.calcExpression(statement.for, data) || []
208
208
  options.extra = options.extra || {}
209
209
 
210
210
  for (let i = 0, len = list.length; i < len; i++) {
@@ -117,6 +117,7 @@ class SelectorQuery {
117
117
  const itemResList = []
118
118
 
119
119
  for (const node of nodes) {
120
+ if (!node) continue
120
121
  const itemRes = {}
121
122
 
122
123
  if (fields.id) {
@@ -166,7 +167,7 @@ class SelectorQuery {
166
167
  itemResList.push(itemRes)
167
168
  }
168
169
 
169
- res.push(isSelectSingle ? itemResList[0] : itemResList)
170
+ res.push(isSelectSingle ? (itemResList[0] || null) : itemResList)
170
171
  }
171
172
 
172
173
  if (typeof this._queueCallback[index] === 'function') this._queueCallback[index].call(this, res[index])
package/src/tool/utils.js CHANGED
@@ -261,6 +261,25 @@ function relativeToAbsolute(basePath, relativePath) {
261
261
  return pathList.join('/')
262
262
  }
263
263
 
264
+ /**
265
+ * 获取 exparser 节点对应的 dom 节点
266
+ */
267
+ function getDom(exparserNode) {
268
+ let dom = exparserNode.$$
269
+ if (!dom) {
270
+ dom = document.createElement('virtual')
271
+ const fragment = document.createDocumentFragment()
272
+ const shadowRoot = exparserNode.shadowRoot
273
+ const childNodes = shadowRoot && shadowRoot.childNodes
274
+ if (childNodes && childNodes.length) {
275
+ childNodes.forEach(child => fragment.appendChild(getDom(child)))
276
+ }
277
+ dom.appendChild(fragment)
278
+ }
279
+
280
+ return dom
281
+ }
282
+
264
283
  module.exports = {
265
284
  getId,
266
285
  copy,
@@ -277,4 +296,5 @@ module.exports = {
277
296
  parseEvent,
278
297
  normalizeAbsolute,
279
298
  relativeToAbsolute,
299
+ getDom,
280
300
  }
package/CHANGELOG.md DELETED
@@ -1,76 +0,0 @@
1
- # 更新日志
2
-
3
- ## 1.4.2
4
-
5
- * 支持 addEventListener/removeEventListener 接口
6
-
7
- ## 1.4.1
8
-
9
- * triggerLifeTime 接口支持参数
10
- * 支持 triggerPageLifeTime 接口
11
-
12
- ## 1.4.0
13
-
14
- * 更新基础库 exparser 到 2.15.0
15
- * 修复 observers 在组件 init 之前就会被调一次的问题
16
-
17
- ## 1.3.3
18
-
19
- * 修复 behavior 创建没有调用 callDefinitionFilter 的问题
20
-
21
- ## 1.3.2
22
-
23
- * 修复 properties 的 type 值转换问题
24
-
25
- ## 1.3.1
26
-
27
- * 随机 id 生成使用 Math.random
28
-
29
- ## 1.3.0
30
-
31
- * 更新基础库 exparser 到 2.11.2
32
- * 支持 virtual host 特性
33
-
34
- ## 1.2.3
35
-
36
- * toJSON 方法将会在 root 组件上返回 `<main/>`
37
- * 修复 wxml 属性简写导致 diff 后属性重复的问题
38
- * 修复部分场景 diff 失败问题
39
-
40
- ## 1.2.2
41
-
42
- * 支持 relations
43
- * 支持了 mutated 事件监听
44
- * 修复无法传递驼峰参数
45
- * 异步事件处理改为微任务
46
-
47
- ## 1.2.1
48
-
49
- * 支持 Component.prototype.toJSON
50
- * 添加 typescript 类型声明
51
-
52
- ## 1.2.0
53
-
54
- * 支持内置 behavior wx://component-export
55
- * 更新 exparser 版本为 2.10.4
56
-
57
- ## 1.1.11
58
-
59
- * 支持内置 behavior wx://form-field-button
60
-
61
- ## 1.1.10
62
-
63
- * 修复节点属性值为 falsely 值被强制转为空字符串的问题
64
-
65
- ## 1.1.9
66
-
67
- * dispatchEvent 接口支持触发自定义事件
68
-
69
- ## 1.1.8
70
-
71
- * 修复 diff 时没有处理父节点为根节点的情况
72
-
73
- ## 1.1.7
74
-
75
- * 废弃注册组件时对初始 data 进行深拷贝的逻辑。
76
- * 修复组件 dispatchEvent 方法中自定义事件传入 detail,组件函数接收不到 detail 的问题(#7)。