From 0b1e4a3efe35b2e4a5500d12e8a3ff9117cad916 Mon Sep 17 00:00:00 2001 From: Igor Nigay Date: Thu, 13 Sep 2018 14:22:16 -0700 Subject: [PATCH] Adds ability to pass object with mode value to shadow prop --- src/utils/registerCustomElement.js | 2 ++ src/vue-custom-element.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/registerCustomElement.js b/src/utils/registerCustomElement.js index b864f04..109a20b 100644 --- a/src/utils/registerCustomElement.js +++ b/src/utils/registerCustomElement.js @@ -7,6 +7,8 @@ export default function registerCustomElement(tag, options = {}) { function constructorCallback() { if (options.shadow === true && HTMLElement.prototype.attachShadow) { this.attachShadow({ mode: 'open' }); + } else if (typeof options.shadow === 'object' && HTMLElement.prototype.attachShadow) { + this.attachShadow(options.shadow); } typeof options.constructorCallback === 'function' && options.constructorCallback.call(this); } diff --git a/src/vue-custom-element.js b/src/vue-custom-element.js index edec486..6421d14 100644 --- a/src/vue-custom-element.js +++ b/src/vue-custom-element.js @@ -74,7 +74,7 @@ function install(Vue) { observedAttributes: props.hyphenate, - shadow: !!options.shadow && !!HTMLElement.prototype.attachShadow + shadow: typeof options.shadow === 'object' ? options.shadow : !!options.shadow && !!HTMLElement.prototype.attachShadow, }); return CustomElement;