Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/runtime-dom/__tests__/customElement.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1774,4 +1774,16 @@ describe('defineCustomElement', () => {
`<el-hyphenated-attr-removal></el-hyphenated-attr-removal>`,
)
})

test('no unexpected mutation of the 1st argument', () => {
const Foo = {
name: 'Foo',
}

defineCustomElement(Foo, { shadowRoot: false })

expect(Foo).toEqual({
name: 'Foo',
})
})
})
4 changes: 2 additions & 2 deletions packages/runtime-dom/src/apiCustomElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ export function defineCustomElement(
*/
_createApp?: CreateAppFunction<Element>,
): VueElementConstructor {
const Comp = defineComponent(options, extraOptions) as any
if (isPlainObject(Comp)) extend(Comp, extraOptions)
let Comp = defineComponent(options, extraOptions) as any
if (isPlainObject(Comp)) Comp = extend({}, Comp, extraOptions)
class VueCustomElement extends VueElement {
static def = Comp
constructor(initialProps?: Record<string, any>) {
Expand Down
Loading