small improvements on html-parser (#4932)

* remove unnecessary code

* not need to capture group when decoding attribute value

* fix eslint
This commit is contained in:
AchillesJ 2017-02-14 22:05:00 +08:00 committed by Evan You
parent 9df7870b7f
commit f763fc2354

View File

@ -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) {