Просмотр исходного кода

small improvements on html-parser (#4932)

* remove unnecessary code

* not need to capture group when decoding attribute value

* fix eslint
AchillesJ 9 лет назад
Родитель
Сommit
f763fc2354
1 измененных файлов с 3 добавлено и 4 удалено
  1. 3 4
      src/compiler/parser/html-parser.js

+ 3 - 4
src/compiler/parser/html-parser.js

@@ -56,8 +56,8 @@ const decodingMap = {
   '&': '&',
   '
': '\n'
 }
-const encodedAttr = /&(lt|gt|quot|amp);/g
-const encodedAttrWithNewLines = /&(lt|gt|quot|amp|#10);/g
+const encodedAttr = /&(?:lt|gt|quot|amp);/g
+const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10);/g
 
 function decodeAttr (value, shouldDecodeNewlines) {
   const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr
@@ -210,7 +210,7 @@ export function parseHTML (html, options) {
 
   function handleStartTag (match) {
     const tagName = match.tagName
-    let unarySlash = match.unarySlash
+    const unarySlash = match.unarySlash
 
     if (expectHTML) {
       if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
@@ -246,7 +246,6 @@ export function parseHTML (html, options) {
     if (!unary) {
       stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs })
       lastTag = tagName
-      unarySlash = ''
     }
 
     if (options.start) {