Skip to content

Commit

Permalink
fix(swan): fix cannot render when use @tarojs/plugin-html
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKonka committed Mar 12, 2024
1 parent 430455f commit 8ce06eb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/taro-plugin-html/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ hooks.tap('modifySetAttrPayload', (element, key, payload, componentsAlias) => {
payload.value = ensureRect(props, element.style.cssText)
}

if (blockElements.has(element.nodeName)) {
if (blockElements.has(element.nodeName) && process.env.TARO_ENV !== 'swan') {
const viewAlias = componentsAlias.view._num
const staticViewAlias = componentsAlias['static-view']._num
const catchViewAlias = componentsAlias['catch-view']._num
Expand Down Expand Up @@ -128,7 +128,7 @@ hooks.tap('modifyRmAttrPayload', (element, key, payload, componentsAlias) => {
payload.value = ensureRect(props, element.style.cssText)
}

if (blockElements.has(element.nodeName)) {
if (blockElements.has(element.nodeName) && process.env.TARO_ENV !== 'swan') {
const viewAlias = componentsAlias.view._num
const staticViewAlias = componentsAlias['static-view']._num
const pureViewAlias = componentsAlias['pure-view']._num
Expand Down Expand Up @@ -201,7 +201,7 @@ hooks.tap('modifyAddEventListener', (element, sideEffect, getComponentsAlias) =>

hooks.tap('modifyRemoveEventListener', (element, sideEffect, getComponentsAlias) => {
// 如果已没有绑定事件,且是 block 元素,则转换为 static-view 或 pure-view
if (blockElements.has(element.nodeName) && sideEffect !== false && !element.isAnyEventBinded()) {
if (process.env.TARO_ENV !== 'swan' && blockElements.has(element.nodeName) && sideEffect !== false && !element.isAnyEventBinded()) {
const componentsAlias = getComponentsAlias()
const value = isHasExtractProp(element) ? 'static-view' : 'pure-view'
const valueAlias = componentsAlias[value]._num
Expand Down
2 changes: 2 additions & 0 deletions packages/taro-plugin-html/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export function getMappedType (nodeName: string, rawProps: Record<string, any>,
const { mapName } = mapping
return isFunction(mapName) ? mapName(rawProps) : mapName
} else {
// fix #15326
if (process.env.TARO_ENV === 'swan') return 'view'
if (node) {
const { props } = node
for (const prop in props) {
Expand Down
7 changes: 6 additions & 1 deletion packages/taro-runtime/src/hydrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ export function hydrate (node: TaroElement | TaroText): MiniData {
) {
data[propInCamelCase] = props[prop]
}
if (nodeName === VIEW && propInCamelCase === CATCHMOVE && props[prop] !== false) {
if (
process.env.TARO_ENV !== 'swan' &&
nodeName === VIEW &&
propInCamelCase === CATCHMOVE &&
props[prop] !== false
) {
data[Shortcuts.NodeName] = CATCH_VIEW
}
if (propInCamelCase === COMPILE_MODE) {
Expand Down
1 change: 1 addition & 0 deletions packages/taro-swan/src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class Template extends RecursiveTemplate {

delete result['pure-view']
delete result['static-view']
delete result['catch-view']

return result
}
Expand Down

0 comments on commit 8ce06eb

Please sign in to comment.