fix(compiler-sfc): compiler blank srcset (#3005)
fix https://github.com/vitejs/vite/issues/1523
This commit is contained in:
parent
ffd5288545
commit
9dc816d634
@ -16,6 +16,10 @@ const _hoisted_8 = \\"/logo.png\\" + ', ' + _imports_0 + '2x'
|
|||||||
|
|
||||||
export function render(_ctx, _cache) {
|
export function render(_ctx, _cache) {
|
||||||
return (_openBlock(), _createBlock(_Fragment, null, [
|
return (_openBlock(), _createBlock(_Fragment, null, [
|
||||||
|
_createVNode(\\"img\\", {
|
||||||
|
src: \\"./logo.png\\",
|
||||||
|
srcset: \\"\\"
|
||||||
|
}),
|
||||||
_createVNode(\\"img\\", {
|
_createVNode(\\"img\\", {
|
||||||
src: \\"./logo.png\\",
|
src: \\"./logo.png\\",
|
||||||
srcset: _hoisted_1
|
srcset: _hoisted_1
|
||||||
@ -69,6 +73,10 @@ exports[`compiler sfc: transform srcset transform srcset w/ base 1`] = `
|
|||||||
|
|
||||||
export function render(_ctx, _cache) {
|
export function render(_ctx, _cache) {
|
||||||
return (_openBlock(), _createBlock(_Fragment, null, [
|
return (_openBlock(), _createBlock(_Fragment, null, [
|
||||||
|
_createVNode(\\"img\\", {
|
||||||
|
src: \\"./logo.png\\",
|
||||||
|
srcset: \\"\\"
|
||||||
|
}),
|
||||||
_createVNode(\\"img\\", {
|
_createVNode(\\"img\\", {
|
||||||
src: \\"./logo.png\\",
|
src: \\"./logo.png\\",
|
||||||
srcset: \\"/foo/logo.png\\"
|
srcset: \\"/foo/logo.png\\"
|
||||||
@ -137,6 +145,10 @@ const _hoisted_11 = \\"data:image/png;base64,i\\" + '1x, ' + \\"data:image/png;b
|
|||||||
|
|
||||||
export function render(_ctx, _cache) {
|
export function render(_ctx, _cache) {
|
||||||
return (_openBlock(), _createBlock(_Fragment, null, [
|
return (_openBlock(), _createBlock(_Fragment, null, [
|
||||||
|
_createVNode(\\"img\\", {
|
||||||
|
src: \\"./logo.png\\",
|
||||||
|
srcset: \\"\\"
|
||||||
|
}),
|
||||||
_createVNode(\\"img\\", {
|
_createVNode(\\"img\\", {
|
||||||
src: \\"./logo.png\\",
|
src: \\"./logo.png\\",
|
||||||
srcset: _hoisted_1
|
srcset: _hoisted_1
|
||||||
|
@ -25,6 +25,7 @@ function compileWithSrcset(template: string, options?: AssetURLOptions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const src = `
|
const src = `
|
||||||
|
<img src="./logo.png" srcset=""/>
|
||||||
<img src="./logo.png" srcset="./logo.png"/>
|
<img src="./logo.png" srcset="./logo.png"/>
|
||||||
<img src="./logo.png" srcset="./logo.png 2x"/>
|
<img src="./logo.png" srcset="./logo.png 2x"/>
|
||||||
<img src="./logo.png" srcset="./logo.png 2x"/>
|
<img src="./logo.png" srcset="./logo.png 2x"/>
|
||||||
|
@ -46,7 +46,7 @@ export const transformSrcset: NodeTransform = (
|
|||||||
if (attr.name === 'srcset' && attr.type === NodeTypes.ATTRIBUTE) {
|
if (attr.name === 'srcset' && attr.type === NodeTypes.ATTRIBUTE) {
|
||||||
if (!attr.value) return
|
if (!attr.value) return
|
||||||
const value = attr.value.content
|
const value = attr.value.content
|
||||||
|
if (!value) return
|
||||||
const imageCandidates: ImageCandidate[] = value.split(',').map(s => {
|
const imageCandidates: ImageCandidate[] = value.split(',').map(s => {
|
||||||
// The attribute value arrives here with all whitespace, except
|
// The attribute value arrives here with all whitespace, except
|
||||||
// normal spaces, represented by escape sequences
|
// normal spaces, represented by escape sequences
|
||||||
|
Loading…
Reference in New Issue
Block a user