Skip to content
Permalink
Browse files
feat(custom-elements): automatically respect custom elements when com…
…piling in browser
  • Loading branch information
yyx990803 committed Aug 30, 2022
1 parent c3465c1 commit 9f8f07ed38b2e003f308875fe3a3e4c0d5477b32
Showing 1 changed file with 13 additions and 10 deletions.
@@ -44,18 +44,21 @@ function compileToFunction(
template = el ? el.innerHTML : ``
}

const { code } = compile(
template,
extend(
{
hoistStatic: true,
onError: __DEV__ ? onError : undefined,
onWarn: __DEV__ ? e => onError(e, true) : NOOP
} as CompilerOptions,
options
)
const opts = extend(
{
hoistStatic: true,
onError: __DEV__ ? onError : undefined,
onWarn: __DEV__ ? e => onError(e, true) : NOOP
} as CompilerOptions,
options
)

if (!opts.isCustomElement && typeof customElements !== 'undefined') {
opts.isCustomElement = tag => !!customElements.get(tag)
}

const { code } = compile(template, opts)

function onError(err: CompilerError, asWarning = false) {
const message = asWarning
? err.message

0 comments on commit 9f8f07e

Please sign in to comment.