]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-sfc): the empty lang attribute should be treated as no lang specified...
authorHcySunYang <HcySunYang@outlook.com>
Wed, 3 Feb 2021 18:11:45 +0000 (02:11 +0800)
committerGitHub <noreply@github.com>
Wed, 3 Feb 2021 18:11:45 +0000 (19:11 +0100)
packages/compiler-sfc/__tests__/parse.spec.ts
packages/compiler-sfc/src/parse.ts

index dc25c848c4163ff1aa8c3cb37a5ab6c394a747f8..aa4b5b48be5c2bfb5e36222f8c7e2f4ce318c4d2 100644 (file)
@@ -139,6 +139,15 @@ h1 { color: red }
     expect(descriptor.template!.content).toBe(content)
   })
 
+  test('treat empty lang attribute as the html', () => {
+    const content = `<div><template v-if="ok">ok</template></div>`
+    const { descriptor, errors } = parse(
+      `<template lang="">${content}</template>`
+    )
+    expect(descriptor.template!.content).toBe(content)
+    expect(errors.length).toBe(0)
+  })
+
   // #1120
   test('alternative template lang should be treated as plain text', () => {
     const content = `p(v-if="1 < 2") test`
index ac3456e645bd54a9fdc9d9c070b9d4733f39bedc..303babe18f02f6ac6301620c1269ef8c08ebc501 100644 (file)
@@ -121,6 +121,7 @@ export function parse(
               p.type === NodeTypes.ATTRIBUTE &&
               p.name === 'lang' &&
               p.value &&
+              p.value.content &&
               p.value.content !== 'html'
           ))
       ) {