From c02e849cb54e923b200fb94b1b80f94f7c9eea63 Mon Sep 17 00:00:00 2001
From: Rich-Harris <richard.a.harris@gmail.com>
Date: Sat, 19 Nov 2016 17:14:15 -0500
Subject: [PATCH] parse comments

---
 compiler/parse/state/tag.js      | 14 ++++++++++++++
 test/parser/comment/input.svelte |  1 +
 test/parser/comment/output.json  | 17 +++++++++++++++++
 3 files changed, 32 insertions(+)
 create mode 100644 test/parser/comment/input.svelte
 create mode 100644 test/parser/comment/output.json

diff --git a/compiler/parse/state/tag.js b/compiler/parse/state/tag.js
index aeb58004a7..cb2178e30d 100644
--- a/compiler/parse/state/tag.js
+++ b/compiler/parse/state/tag.js
@@ -22,6 +22,20 @@ const specials = {
 export default function tag ( parser ) {
 	const start = parser.index++;
 
+	if ( parser.eat( '!--' ) ) {
+		const data = parser.readUntil( /-->/ );
+		parser.eat( '-->' );
+
+		parser.current().children.push({
+			start,
+			end: parser.index,
+			type: 'Comment',
+			data
+		});
+
+		return null;
+	}
+
 	const isClosingTag = parser.eat( '/' );
 
 	// TODO handle cases like <li>one<li>two
diff --git a/test/parser/comment/input.svelte b/test/parser/comment/input.svelte
new file mode 100644
index 0000000000..b35c49dac8
--- /dev/null
+++ b/test/parser/comment/input.svelte
@@ -0,0 +1 @@
+<!-- a comment -->
diff --git a/test/parser/comment/output.json b/test/parser/comment/output.json
new file mode 100644
index 0000000000..635c0fc2e0
--- /dev/null
+++ b/test/parser/comment/output.json
@@ -0,0 +1,17 @@
+{
+	"html": {
+		"start": 0,
+		"end": 18,
+		"type": "Fragment",
+		"children": [
+			{
+				"start": 0,
+				"end": 18,
+				"type": "Comment",
+				"data": " a comment "
+			}
+		]
+	},
+	"css": null,
+	"js": null
+}