Skip to content

Commit

Permalink
feat(custom-elements): automatically respect custom elements when com…
Browse files Browse the repository at this point in the history
…piling in browser
  • Loading branch information
yyx990803 committed Aug 30, 2022
1 parent c3465c1 commit 9f8f07e
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions packages/vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9f8f07e

Please sign in to comment.