Skip to content

Commit

Permalink
fix(compiler-sfc): compiler blank srcset (#3005)
Browse files Browse the repository at this point in the history
  • Loading branch information
underfin authored Feb 3, 2021
1 parent ffd5288 commit 9dc816d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const _hoisted_8 = \\"/logo.png\\" + ', ' + _imports_0 + '2x'
export function render(_ctx, _cache) {
return (_openBlock(), _createBlock(_Fragment, null, [
_createVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: \\"\\"
}),
_createVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: _hoisted_1
Expand Down Expand Up @@ -69,6 +73,10 @@ exports[`compiler sfc: transform srcset transform srcset w/ base 1`] = `
export function render(_ctx, _cache) {
return (_openBlock(), _createBlock(_Fragment, null, [
_createVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: \\"\\"
}),
_createVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: \\"/foo/logo.png\\"
Expand Down Expand Up @@ -137,6 +145,10 @@ const _hoisted_11 = \\"data:image/png;base64,i\\" + '1x, ' + \\"data:image/png;b
export function render(_ctx, _cache) {
return (_openBlock(), _createBlock(_Fragment, null, [
_createVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: \\"\\"
}),
_createVNode(\\"img\\", {
src: \\"./logo.png\\",
srcset: _hoisted_1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function compileWithSrcset(template: string, options?: AssetURLOptions) {
}

const src = `
<img src="./logo.png" srcset=""/>
<img src="./logo.png" srcset="./logo.png"/>
<img src="./logo.png" srcset="./logo.png 2x"/>
<img src="./logo.png" srcset="./logo.png 2x"/>
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-sfc/src/templateTransformSrcset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const transformSrcset: NodeTransform = (
if (attr.name === 'srcset' && attr.type === NodeTypes.ATTRIBUTE) {
if (!attr.value) return
const value = attr.value.content

if (!value) return
const imageCandidates: ImageCandidate[] = value.split(',').map(s => {
// The attribute value arrives here with all whitespace, except
// normal spaces, represented by escape sequences
Expand Down

0 comments on commit 9dc816d

Please sign in to comment.