* 内部所有节点创建都走此接口,统一把控
(options, tree)
| 203 | * 内部所有节点创建都走此接口,统一把控 |
| 204 | */ |
| 205 | $$createElement(options, tree) { |
| 206 | const originTagName = options.tagName |
| 207 | const tagName = originTagName.toUpperCase() |
| 208 | let wxComponentName = null |
| 209 | tree = tree || this.$_tree |
| 210 | |
| 211 | const constructorClass = CONSTRUCTOR_MAP[tagName] |
| 212 | if (constructorClass) { |
| 213 | return constructorClass.$$create(options, tree) |
| 214 | } else if (tagName === 'WX-COMPONENT') { |
| 215 | options.attrs = options.attrs || {} |
| 216 | const behavior = options.attrs.behavior |
| 217 | if (behavior && WX_COMPONENT_TRANSFORM_LIST.indexOf(behavior) !== -1) return transformWxComponent2Dom(behavior, options, tree) // 需要转成普通 dom |
| 218 | else return WxComponent.$$create(options, tree) |
| 219 | // eslint-disable-next-line no-cond-assign |
| 220 | } else if (wxComponentName = tool.checkIsWxComponent(originTagName, this.$$notNeedPrefix)) { |
| 221 | // 内置组件的特殊写法,转成 wx-component 节点 |
| 222 | options.attrs = options.attrs || {} |
| 223 | if (WX_COMPONENT_TRANSFORM_LIST.indexOf(wxComponentName) !== -1) return transformWxComponent2Dom(wxComponentName, options, tree) // 需要转成普通 dom |
| 224 | else { |
| 225 | options.tagName = 'wx-component' |
| 226 | options.attrs.behavior = wxComponentName |
| 227 | return WxComponent.$$create(options, tree) |
| 228 | } |
| 229 | } else if (WX_CUSTOM_COMPONENT_MAP[originTagName]) { |
| 230 | // 自定义组件的特殊写法,转成 wx-custom-component 节点 |
| 231 | options.tagName = 'wx-custom-component' |
| 232 | options.attrs = options.attrs || {} |
| 233 | options.componentName = originTagName |
| 234 | return WxCustomComponent.$$create(options, tree) |
| 235 | } else if (!tool.isTagNameSupport(tagName)) { |
| 236 | return NotSupport.$$create(options, tree) |
| 237 | } else { |
| 238 | return Element.$$create(options, tree) |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | /** |
| 243 | * 内部所有文本节点创建都走此接口,统一把控 |
no test coverage detected