diff --git a/.cloudbuild/test.yml b/.cloudbuild/test.yml index a5c7242f..10f27393 100644 --- a/.cloudbuild/test.yml +++ b/.cloudbuild/test.yml @@ -13,7 +13,7 @@ env: resource: type: docker image: kweecr04.his.huawei.com:80/ecr-build-arm-gzkunpeng/euleros_v2r7spc522_x64_opmt_cs5.0_sz:v5.0 - class: 4U8G + class: 8U16G mode: toolbox cache: - type: workspace diff --git a/libs/horizon/src/dom/DOMPropertiesHandler/StyleHandler.ts b/libs/horizon/src/dom/DOMPropertiesHandler/StyleHandler.ts index 3c3a9a24..e2fca141 100644 --- a/libs/horizon/src/dom/DOMPropertiesHandler/StyleHandler.ts +++ b/libs/horizon/src/dom/DOMPropertiesHandler/StyleHandler.ts @@ -33,6 +33,17 @@ const noUnitCSS = [ 'zoom', ]; +const length = noUnitCSS.length; +for (let i = 0; i < length; i++) { + const cssKey = noUnitCSS[i]; + const attributeKey = cssKey.charAt(0).toUpperCase() + cssKey.slice(1); + + // css 兼容性前缀 webkit: chrome, mo: IE或者Edge, Moz: 火狐 + noUnitCSS.push('Webkit' + attributeKey); + noUnitCSS.push('mo' + attributeKey); + noUnitCSS.push('Moz' + attributeKey); +} + function isNeedUnitCSS(styleName: string) { return !( noUnitCSS.includes(styleName) || @@ -78,6 +89,7 @@ export function setStyles(dom, styles) { if (name.indexOf('--') === 0) { style.setProperty(name, styleVal); } else { + // 使用这种赋值方式,浏览器可以将'WebkitLineClamp', 'backgroundColor'分别识别为'-webkit-line-clamp'和'backgroud-color' style[name] = adjustStyleValue(name, styleVal); } }); diff --git a/scripts/__tests__/DomTest/Attribute.test.js b/scripts/__tests__/DomTest/Attribute.test.js index 90823780..56004668 100755 --- a/scripts/__tests__/DomTest/Attribute.test.js +++ b/scripts/__tests__/DomTest/Attribute.test.js @@ -83,6 +83,12 @@ describe('Dom Attribute', () => { expect(window.getComputedStyle(div).getPropertyValue('height')).toBe('20px'); }); + it('WebkitLineClamp和lineClamp样式不会把数字转换成字符串或者追加"px"', () => { + Horizon.render(
, container); + // 浏览器可以将WebkitLineClamp识别为-webkit-line-clamp,测试框架不可以 + expect(container.querySelector('div').style.WebkitLineClamp).toBe(2); + }); + it('空字符串做属性名', () => { const emptyStringProps = { '': '' }; expect(() => {