Skip to content

Commit 9f8f07e

Browse files
committed
feat(custom-elements): automatically respect custom elements when compiling in browser
1 parent c3465c1 commit 9f8f07e

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

packages/vue/src/index.ts

+13-10
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,21 @@ function compileToFunction(
4444
template = el ? el.innerHTML : ``
4545
}
4646

47-
const { code } = compile(
48-
template,
49-
extend(
50-
{
51-
hoistStatic: true,
52-
onError: __DEV__ ? onError : undefined,
53-
onWarn: __DEV__ ? e => onError(e, true) : NOOP
54-
} as CompilerOptions,
55-
options
56-
)
47+
const opts = extend(
48+
{
49+
hoistStatic: true,
50+
onError: __DEV__ ? onError : undefined,
51+
onWarn: __DEV__ ? e => onError(e, true) : NOOP
52+
} as CompilerOptions,
53+
options
5754
)
5855

56+
if (!opts.isCustomElement && typeof customElements !== 'undefined') {
57+
opts.isCustomElement = tag => !!customElements.get(tag)
58+
}
59+
60+
const { code } = compile(template, opts)
61+
5962
function onError(err: CompilerError, asWarning = false) {
6063
const message = asWarning
6164
? err.message

0 commit comments

Comments
 (0)