Skip to content

Commit

Permalink
fix(shared/runtime): 修复 vant weapp 兼容问题,fix #10337
Browse files Browse the repository at this point in the history
1. 可以传递 class 属性
2. 可以传递函数类型属性
  • Loading branch information
Chen-jj committed Dec 9, 2021
1 parent dcca9f5 commit cf77ed4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/shared/src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ export class BaseTemplate {
value = `:${value}`
}
return str + `bind${value}="eh" `
} else if (attr === 'class') {
return str + `class="{{i.${Shortcuts.Class}}}" `
}

return str + `${attr}="{{i.${toCamelCase(attr)}}}" `
Expand Down
4 changes: 2 additions & 2 deletions packages/taro-runtime/src/dom/element.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { inject, injectable } from 'inversify'
import { isArray, isUndefined, Shortcuts, EMPTY_OBJ, warn, isString, toCamelCase } from '@tarojs/shared'
import { isArray, isUndefined, Shortcuts, EMPTY_OBJ, warn, isString, toCamelCase, isFunction } from '@tarojs/shared'
import SERVICE_IDENTIFIER from '../constants/identifiers'
import { TaroNode } from './node'
import { NodeType } from './node_types'
Expand Down Expand Up @@ -174,7 +174,7 @@ export class TaroElement extends TaroNode {

const payload = {
path: `${this._path}.${toCamelCase(qualifiedName)}`,
value
value: isFunction(value) ? () => value : value
}

this.hooks.modifySetAttrPayload?.(this, qualifiedName, payload)
Expand Down

0 comments on commit cf77ed4

Please sign in to comment.