]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-core): relax error on unknown entities
authorEvan You <yyx990803@gmail.com>
Wed, 29 Jan 2020 17:16:58 +0000 (12:16 -0500)
committerEvan You <yyx990803@gmail.com>
Wed, 29 Jan 2020 17:16:58 +0000 (12:16 -0500)
close #663

packages/compiler-core/__tests__/__snapshots__/parse.spec.ts.snap
packages/compiler-core/__tests__/parse.spec.ts
packages/compiler-core/src/errors.ts
packages/compiler-core/src/parse.ts

index d2ec37c611b823f3a488b07bd2b089d344396cca..f6aa2ece7c5bc860c09a5f687120a35c24d84498 100644 (file)
@@ -6956,75 +6956,6 @@ Object {
 }
 `;
 
-exports[`compiler: parse Errors UNKNOWN_NAMED_CHARACTER_REFERENCE <template>&unknown;</template> 1`] = `
-Object {
-  "cached": 0,
-  "children": Array [
-    Object {
-      "children": Array [
-        Object {
-          "content": "&unknown;",
-          "loc": Object {
-            "end": Object {
-              "column": 20,
-              "line": 1,
-              "offset": 19,
-            },
-            "source": "&unknown;",
-            "start": Object {
-              "column": 11,
-              "line": 1,
-              "offset": 10,
-            },
-          },
-          "type": 2,
-        },
-      ],
-      "codegenNode": undefined,
-      "isSelfClosing": false,
-      "loc": Object {
-        "end": Object {
-          "column": 31,
-          "line": 1,
-          "offset": 30,
-        },
-        "source": "<template>&unknown;</template>",
-        "start": Object {
-          "column": 1,
-          "line": 1,
-          "offset": 0,
-        },
-      },
-      "ns": 0,
-      "props": Array [],
-      "tag": "template",
-      "tagType": 3,
-      "type": 1,
-    },
-  ],
-  "codegenNode": undefined,
-  "components": Array [],
-  "directives": Array [],
-  "helpers": Array [],
-  "hoists": Array [],
-  "imports": Array [],
-  "loc": Object {
-    "end": Object {
-      "column": 31,
-      "line": 1,
-      "offset": 30,
-    },
-    "source": "<template>&unknown;</template>",
-    "start": Object {
-      "column": 1,
-      "line": 1,
-      "offset": 0,
-    },
-  },
-  "type": 0,
-}
-`;
-
 exports[`compiler: parse Errors X_INVALID_END_TAG <svg><![CDATA[</div>]]></svg> 1`] = `
 Object {
   "cached": 0,
index 037e9377f819cdedc9cd73238b73d8a9fcac43bf..53263f8d54d549aad48c5776b732faa9941edf70 100644 (file)
@@ -2594,17 +2594,6 @@ foo
           ]
         }
       ],
-      UNKNOWN_NAMED_CHARACTER_REFERENCE: [
-        {
-          code: '<template>&unknown;</template>',
-          errors: [
-            {
-              type: ErrorCodes.UNKNOWN_NAMED_CHARACTER_REFERENCE,
-              loc: { offset: 10, line: 1, column: 11 }
-            }
-          ]
-        }
-      ],
       X_INVALID_END_TAG: [
         {
           code: '<template></div></template>',
index c62d12b9f9918aabc8bd09c31840d5223d26d0b2..e2fe090a050787b4c0d2713cea1c84d1ca546783 100644 (file)
@@ -57,7 +57,6 @@ export const enum ErrorCodes {
   UNEXPECTED_NULL_CHARACTER,
   UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME,
   UNEXPECTED_SOLIDUS_IN_TAG,
-  UNKNOWN_NAMED_CHARACTER_REFERENCE,
 
   // Vue-specific parse errors
   X_INVALID_END_TAG,
@@ -141,7 +140,6 @@ export const errorMessages: { [code: number]: string } = {
   [ErrorCodes.UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME]:
     "'<?' is allowed only in XML context.",
   [ErrorCodes.UNEXPECTED_SOLIDUS_IN_TAG]: "Illegal '/' in tags.",
-  [ErrorCodes.UNKNOWN_NAMED_CHARACTER_REFERENCE]: 'Unknown entity name.',
 
   // Vue-specific parse errors
   [ErrorCodes.X_INVALID_END_TAG]: 'Invalid end tag.',
index 7d46f8ea35333818dc72f0a8dc5fe1fd196d3e55..9b2425c09c88137585ecf118757d45a54f274745 100644 (file)
@@ -820,8 +820,8 @@ function parseTextData(
 
     if (head[0] === '&') {
       // Named character reference.
-      let name = '',
-        value: string | undefined = undefined
+      let name = ''
+      let value: string | undefined = undefined
       if (/[0-9a-z]/i.test(rawText[1])) {
         for (
           let length = context.options.maxCRNameLength;
@@ -836,7 +836,7 @@ function parseTextData(
           if (
             mode === TextModes.ATTRIBUTE_VALUE &&
             !semi &&
-            /[=a-z0-9]/i.test(rawText[1 + name.length] || '')
+            /[=a-z0-9]/i.test(rawText[name.length + 1] || '')
           ) {
             decodedText += '&' + name
             advance(1 + name.length)
@@ -851,7 +851,6 @@ function parseTextData(
             }
           }
         } else {
-          emitError(context, ErrorCodes.UNKNOWN_NAMED_CHARACTER_REFERENCE)
           decodedText += '&' + name
           advance(1 + name.length)
         }