From b7efcbe40044905eab3c37df919275d24826ca57 Mon Sep 17 00:00:00 2001 From: Zephraph Date: Tue, 23 Apr 2019 19:48:30 -0400 Subject: [PATCH] Set defaults for shadowDom and fail if in a bad config state --- src/compile/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/compile/index.ts b/src/compile/index.ts index 7533b891e7..9fadde3d36 100644 --- a/src/compile/index.ts +++ b/src/compile/index.ts @@ -29,7 +29,7 @@ const valid_options = [ ]; function validate_options(options: CompileOptions, warnings: Warning[]) { - const { name, filename } = options; + const { name, filename, shadowDom, customElement } = options; Object.keys(options).forEach(key => { if (valid_options.indexOf(key) === -1) { @@ -54,6 +54,10 @@ function validate_options(options: CompileOptions, warnings: Warning[]) { toString: () => message, }); } + + if (!customElement && shadowDom) { + throw new Error(`options.shadowDom cannot be true if options.customElement is false`) + } } function get_name(filename) { @@ -75,7 +79,7 @@ function get_name(filename) { } export default function compile(source: string, options: CompileOptions = {}) { - options = assign({ generate: 'dom', dev: false }, options); + options = assign({ generate: 'dom', dev: false, shadowDom: options.customElement }, options); const stats = new Stats(); const warnings = [];