@tarojsx/library
Version:
Taro3 library
26 lines • 1.04 kB
JavaScript
import { __rest } from "tslib";
import { toDashed } from '../utils';
// const applyAnimatedValuesWeb = Globals.applyAnimatedValues
/**
* TaroElement 设置 style 属性比设置字符串 cssText 理论上性能更高, 这种方式可以跳过 react setState, 但是逃不过小程序 setData.
*
* 在碰到兼容问题前, 暂时交由 spring web 处理 style.
*
* 1. TaroElement.style[name] = value
* 2. TaroElement.setAttribute('style', styleString)
*/
export const applyAnimatedValues = (instance, props) => {
if (!instance.nodeType || !instance.setAttribute) {
return false;
}
const _a = props, { style = {} } = _a, attributes = __rest(_a, ["style"]);
const styleString = Object.keys(style).reduce((str, key) => {
const val = style[key];
return val ? `${str}${toDashed(key)}: ${val};` : str;
}, '');
if (styleString) {
instance.setAttribute('style', styleString);
}
// applyAnimatedValuesWeb(instance, attributes)
};
//# sourceMappingURL=applyAnimatedValues.js.map