From 67f5dc6b14512e4752e6c73ec3889029d62811dd Mon Sep 17 00:00:00 2001 From: niris Date: Thu, 19 Jan 2017 17:32:52 +0800 Subject: [PATCH 1/2] fix(sfc): component contains '<' only --- src/compiler/parser/html-parser.js | 3 +++ test/unit/modules/sfc/sfc-parser.spec.js | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/compiler/parser/html-parser.js b/src/compiler/parser/html-parser.js index fabe264e5f6..75accee5703 100644 --- a/src/compiler/parser/html-parser.js +++ b/src/compiler/parser/html-parser.js @@ -120,6 +120,9 @@ export function parseHTML (html, options) { handleStartTag(startTagMatch) continue } + + // < in plain text, treat it as text + advance(1) } let text, rest, next diff --git a/test/unit/modules/sfc/sfc-parser.spec.js b/test/unit/modules/sfc/sfc-parser.spec.js index 4437d516adb..6747b9167e9 100644 --- a/test/unit/modules/sfc/sfc-parser.spec.js +++ b/test/unit/modules/sfc/sfc-parser.spec.js @@ -78,6 +78,15 @@ describe('Single File Component parser', () => { expect(res.template.content.trim()).toBe(`div\n h1(v-if='1 < 2') hello`) }) + it('should handle component contains "<" only', () => { + const res = parseComponent(` + + `) + expect(res.template.content.trim()).toBe(`<`) + }) + it('should handle custom blocks without parsing them', () => { const res = parseComponent(`