From 21c301b81a2f26a9397d8adb31c3cd6f5388a3e0 Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Sat, 24 Nov 2018 23:48:33 -0800 Subject: [PATCH] Parse disable and enable comments --- src/compile/Component.ts | 6 ++++++ src/compile/nodes/Comment.ts | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/compile/Component.ts b/src/compile/Component.ts index 4a249d2287..ca0ff8b5ba 100644 --- a/src/compile/Component.ts +++ b/src/compile/Component.ts @@ -92,6 +92,7 @@ childKeys.Attribute = ['value']; export default class Component { stats: Stats; + disableWarn: boolean; ast: Ast; source: string; @@ -164,6 +165,7 @@ export default class Component { stats: Stats ) { this.stats = stats; + this.disableWarn = false; this.ast = ast; this.source = source; @@ -541,6 +543,10 @@ export default class Component { message: string } ) { + if (this.disableWarn) { + return; + } + if (!this.locator) { this.locator = getLocator(this.source, { offsetLine: 1 }); } diff --git a/src/compile/nodes/Comment.ts b/src/compile/nodes/Comment.ts index 97a28f25a1..9b8748d576 100644 --- a/src/compile/nodes/Comment.ts +++ b/src/compile/nodes/Comment.ts @@ -7,5 +7,12 @@ export default class Comment extends Node { constructor(component, parent, scope, info) { super(component, parent, scope, info); this.data = info.data; + + const value = this.data.trim(); + if (value === 'svelte-disable') { + component.disableWarn = true; + } else if (value === 'svelte-enable') { + component.disableWarn = false; + } } } \ No newline at end of file