فهرست منبع

template parser: improve HTML entity regex (fix #1330)

Evan You 10 سال پیش
والد
کامیت
7ce035d99d
2فایلهای تغییر یافته به همراه6 افزوده شده و 1 حذف شده
  1. 1 1
      src/parsers/template.js
  2. 5 0
      test/unit/specs/parsers/template_spec.js

+ 1 - 1
src/parsers/template.js

@@ -70,7 +70,7 @@ function isRealTemplate (node) {
 }
 
 var tagRE = /<([\w:]+)/
-var entityRE = /&\w+;/
+var entityRE = /&\w+;|&#\d+;|&#x[\dA-F]+;/
 
 /**
  * Convert a string template to a DocumentFragment.

+ 5 - 0
test/unit/specs/parsers/template_spec.js

@@ -42,6 +42,11 @@ if (_.inBrowser) {
       expect(res instanceof DocumentFragment).toBeTruthy()
       expect(res.childNodes.length).toBe(1)
       expect(res.firstChild.nodeValue).toBe('hi<hi')
+      // #1330
+      res = parse('hello &#x2F; hello')
+      expect(res instanceof DocumentFragment).toBeTruthy()
+      expect(res.childNodes.length).toBe(1)
+      expect(res.firstChild.nodeValue).toBe('hello / hello')
     })
 
     it('should parse textContent if argument is a script node', function () {