mirror of https://github.com/vuejs/core.git
fix(compiler-sfc): transform empty srcset w/ includeAbsolute: true (#13639)
close vitejs/vite-plugin-vue#631
This commit is contained in:
parent
90573b06bf
commit
d8e40ef7e1
|
@ -16,6 +16,16 @@ export function render(_ctx, _cache) {
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`compiler sfc: transform srcset > transform empty srcset w/ includeAbsolute: true 1`] = `
|
||||||
|
"import { openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue"
|
||||||
|
|
||||||
|
const _hoisted_1 = { srcset: " " }
|
||||||
|
|
||||||
|
export function render(_ctx, _cache) {
|
||||||
|
return (_openBlock(), _createElementBlock("img", _hoisted_1))
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`compiler sfc: transform srcset > transform srcset 1`] = `
|
exports[`compiler sfc: transform srcset > transform srcset 1`] = `
|
||||||
"import { createElementVNode as _createElementVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue"
|
"import { createElementVNode as _createElementVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue"
|
||||||
import _imports_0 from './logo.png'
|
import _imports_0 from './logo.png'
|
||||||
|
|
|
@ -72,6 +72,14 @@ describe('compiler sfc: transform srcset', () => {
|
||||||
).toMatchSnapshot()
|
).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('transform empty srcset w/ includeAbsolute: true', () => {
|
||||||
|
expect(
|
||||||
|
compileWithSrcset(`<img srcset=" " />`, {
|
||||||
|
includeAbsolute: true,
|
||||||
|
}).code,
|
||||||
|
).toMatchSnapshot()
|
||||||
|
})
|
||||||
|
|
||||||
test('transform srcset w/ stringify', () => {
|
test('transform srcset w/ stringify', () => {
|
||||||
const code = compileWithSrcset(
|
const code = compileWithSrcset(
|
||||||
`<div>${src}</div>`,
|
`<div>${src}</div>`,
|
||||||
|
|
|
@ -71,6 +71,7 @@ export const transformSrcset: NodeTransform = (
|
||||||
|
|
||||||
const shouldProcessUrl = (url: string) => {
|
const shouldProcessUrl = (url: string) => {
|
||||||
return (
|
return (
|
||||||
|
url &&
|
||||||
!isExternalUrl(url) &&
|
!isExternalUrl(url) &&
|
||||||
!isDataUrl(url) &&
|
!isDataUrl(url) &&
|
||||||
(options.includeAbsolute || isRelativeUrl(url))
|
(options.includeAbsolute || isRelativeUrl(url))
|
||||||
|
|
Loading…
Reference in New Issue