Skip to content

Commit

Permalink
feat(mini-runner): 为vue增加custom-wrapper,fix #8989
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen-jj committed May 6, 2021
1 parent 329c57a commit ad97018
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/taro-mini-runner/src/webpack/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { REG_VUE, chalk } from '@tarojs/helper'
import { toCamelCase, internalComponents, capitalize } from '@tarojs/shared'
import { componentConfig } from '../template/component'

const CUSTOM_WRAPPER = 'custom-wrapper'

export function customVueChain (chain) {
let vueLoaderPath: string
try {
Expand Down Expand Up @@ -43,6 +45,10 @@ export function customVueChain (chain) {
componentConfig.includes.add(nodeName)
}

if (nodeName === CUSTOM_WRAPPER) {
componentConfig.thirdPartyComponents.set(CUSTOM_WRAPPER, new Set())
}

const usingComponent = componentConfig.thirdPartyComponents.get(nodeName)
if (usingComponent != null) {
el.attrsList
Expand Down
7 changes: 7 additions & 0 deletions packages/taro-mini-runner/src/webpack/vue3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { toCamelCase, internalComponents, capitalize } from '@tarojs/shared'
import { componentConfig } from '../template/component'
import type { RootNode, TemplateChildNode, ElementNode, AttributeNode, DirectiveNode, SimpleExpressionNode } from '@vue/compiler-core'

const CUSTOM_WRAPPER = 'custom-wrapper'

export function customVue3Chain (chain) {
let vueLoaderPath: string
try {
Expand Down Expand Up @@ -62,6 +64,11 @@ export function customVue3Chain (chain) {
componentConfig.includes.add(nodeName)
}

if (nodeName === CUSTOM_WRAPPER) {
node.tagType = 0 /* ELEMENT */
componentConfig.thirdPartyComponents.set(CUSTOM_WRAPPER, new Set())
}

const usingComponent = componentConfig.thirdPartyComponents.get(nodeName)
if (usingComponent != null) {
node.props.forEach(prop => {
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-runtime/src/dom/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class TaroRootElement extends TaroElement {
eventCenter.trigger(eventId)
})
})
ctx.setData(normalUpdate, () => {
Object.keys(normalUpdate).length && ctx.setData(normalUpdate, () => {
eventCenter.trigger(eventId)
})
} else {
Expand Down

0 comments on commit ad97018

Please sign in to comment.