Skip to content

Commit 8e58b32

Browse files
author
KPH
committed
fix:image alt
1 parent 6d8cfad commit 8e58b32

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

packages/hap-compiler/src/template/validator.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,12 +1864,7 @@ function checkAttr(name, value, output, tagName, locationInfo, options) {
18641864
* @returns {boolean}
18651865
*/
18661866
function shouldConvertPath(name, value, tagName) {
1867-
const skip = name === 'alt' && value === 'blank'
1868-
if (skip) {
1869-
return false
1870-
}
1871-
1872-
if (['src', 'alt'].includes(name) && value && ['img', 'video'].indexOf(tagName) > -1) {
1867+
if (['src'].includes(name) && value && ['img', 'video'].indexOf(tagName) > -1) {
18731868
if (!/^(data:|http|{{)/.test(value)) {
18741869
return true
18751870
}

packages/hap-dsl-xvm/test/unit/ux/__snapshots__/component.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,15 +2250,15 @@ exports[`Component 编译测试 ux components: ../../../lib/loaders/template-loa
22502250
\\"attr\\": {
22512251
\\"dataData2\\": function () {return this.attrData},
22522252
\\"src\\": \\"/packages/hap-dsl-xvm/test/case/ux/TestComponent/Image/Common/home.png\\",
2253-
\\"alt\\": \\"/packages/hap-dsl-xvm/test/case/ux/TestComponent/Image/Common/home.png\\"
2253+
\\"alt\\": \\"./Common/home.png\\"
22542254
}
22552255
},
22562256
{
22572257
\\"type\\": \\"image\\",
22582258
\\"attr\\": {
22592259
\\"dataData1Data2\\": \\"abc\\",
22602260
\\"src\\": \\"/packages/hap-dsl-xvm/test/case/ux/TestComponent/Common/home.png\\",
2261-
\\"alt\\": \\"/packages/hap-dsl-xvm/test/case/ux/TestComponent/Common/home.png\\"
2261+
\\"alt\\": \\"../Common/home.png\\"
22622262
}
22632263
},
22642264
{
Binary file not shown.

0 commit comments

Comments
 (0)