Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runtime-core): #7203 - adds support for custom element hydration #7300

Closed
wants to merge 183 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
183 commits
Select commit Hold shift + click to select a range
d445b31
fix(runtime-core): #7203 - adds support for custom element hydration
steveworkman Dec 8, 2022
3ccd929
chore(runtime-core): removed console.log from unit test
steveworkman Dec 8, 2022
510abf9
Merge remote-tracking branch 'origin/main' into feat/7203-custom-elem…
steveworkman Jan 12, 2023
81587b3
fix(runtime-core): registered custom elements should have all properi…
steveworkman Jan 12, 2023
6584906
test: removed changes to unrelated test
steveworkman Jan 12, 2023
95d92b3
fix: added isCustomElement check for patching in production
steveworkman Jan 13, 2023
277f198
chore: run format
antfu Jan 12, 2023
0e314ee
chore: apply format
antfu Jan 12, 2023
2070d17
fix(shared): `feDistanceLight` changed to `feDistantLight` (#7540)
baiwusanyu-c Jan 16, 2023
6a27b80
fix(build): ensure cjs re-exports can be properly detected when impor…
yyx990803 Jan 20, 2023
1431554
fix(build): fix cjs re-exports check for compat build
yyx990803 Jan 21, 2023
f3bcf00
chore: bump vite and esbuild
yyx990803 Jan 26, 2023
591088f
build: update build scripts to esm
yyx990803 Jan 26, 2023
88b6c92
wip(vitest-migration): reactivity tests passing
yyx990803 Jan 26, 2023
ba02d6e
wip(vitest-migration): shared tests passing
yyx990803 Jan 26, 2023
906d0eb
build: fix build script
yyx990803 Jan 26, 2023
8a795e5
wip(vitest-migration): ssr tests passing
yyx990803 Jan 26, 2023
834b1bb
wip(vitest-migration): compiler-core tests passing
yyx990803 Jan 26, 2023
959aa9f
wip(vitest-migration): compiler-dom tests passing
yyx990803 Jan 26, 2023
53ac665
wip(vitest-migration): compiler-sfc tests passing
yyx990803 Jan 26, 2023
6689aef
wip(vitest-migration): compiler-ssr tests passing
yyx990803 Jan 26, 2023
1bcb239
wip(vitest-migration): compat tests passing
yyx990803 Jan 26, 2023
3480d4b
wip(vitest-migration): runtime-core tests passing
yyx990803 Jan 26, 2023
ec015f1
chore: only wrap during tests
yyx990803 Jan 26, 2023
a628079
wip(vitest-migration): runtime-dom tests passing + use environmentMat…
yyx990803 Jan 26, 2023
3a24538
wip(vitest-migration): all tests passing
yyx990803 Jan 26, 2023
8dce248
workflow: complete migration from jest to vitest
yyx990803 Jan 26, 2023
657b5a3
chore: replace test global types with vitest types
yyx990803 Jan 26, 2023
5542380
chore: explicitly install jsdom
yyx990803 Jan 26, 2023
afd9a00
ci: fix dts tests
yyx990803 Jan 26, 2023
7687d82
test: configure test hooks sequence order, remove workaround
yyx990803 Jan 27, 2023
df1cfd1
chore: fix broken link (#7589)
vaakian Jan 27, 2023
1f393c4
build: do not throw when running `build --release` for the 1st time (…
haoqunjiang Jan 27, 2023
0b2fe2e
chore: remove debugging log
sxzz Jan 29, 2023
f485765
chore: remove unused import
yyx990803 Jan 30, 2023
16684ec
fix(build): ensure type exports is first
yyx990803 Feb 1, 2023
f8ffe58
test: fix await patch prop case (#7600)
sxzz Feb 1, 2023
a6b4821
chore: update caniuse
yyx990803 Feb 1, 2023
427e1b6
ci: bump netlify node version
yyx990803 Feb 1, 2023
94c0ba7
fix(types): accept sync `serverPrefetch()` (#7000)
antfu Feb 1, 2023
a582afe
fix(reactivity): `triggerRef` working with `toRef` from reactive (#7507)
antfu Feb 1, 2023
2ea880c
fix(compat): fix custom transition classes in compat mode (#7435)
SxDx Feb 1, 2023
b13c051
chore: fix jest reference in merged test case
yyx990803 Feb 1, 2023
b449ea0
fix(runtime-core): fix keep-alive cache prune logic on vnodes with sa…
GRPdream Feb 1, 2023
1765323
fix(compiler-sfc): support resolving type declaration from normal scr…
edison1105 Feb 1, 2023
2a61107
fix(types): optional boolean props should have boolean type in return…
sxzz Feb 2, 2023
6d1a482
workflow: check ci status during release
yyx990803 Feb 2, 2023
45dc8f7
release: v3.2.46
yyx990803 Feb 2, 2023
73e426a
fix(build): enforce __esModule interop for cjs builds
yyx990803 Feb 2, 2023
d47a1b2
release: v3.2.47
yyx990803 Feb 2, 2023
a75d185
chore: fix types
yyx990803 Feb 2, 2023
0f62bdb
chore: fix size reporting for brotli
yyx990803 Feb 2, 2023
53c83c1
fix(build): ensure BaseTransition functions can be tree-shaken
yyx990803 Feb 2, 2023
040ede5
chore: define compile time flags during size check
yyx990803 Feb 2, 2023
2836dcc
workflow: disable threads during tests
yyx990803 Feb 2, 2023
92f2cf0
build: only enable esModule compat for cjs builds
yyx990803 Feb 2, 2023
65dd0c5
wip: isolatedModules + use rollup-plugin-esbuild
yyx990803 Feb 2, 2023
7bd9e7b
chore: remove rpts2
yyx990803 Feb 2, 2023
ceb5f37
workflow: type check on commit
yyx990803 Feb 2, 2023
929407d
chore: remove hanging slash from import
yyx990803 Feb 2, 2023
ed672eb
build: refactor rollup config
yyx990803 Feb 2, 2023
710ae60
chore: bump deps
yyx990803 Feb 2, 2023
9c3c09b
build: custom const enum processing
yyx990803 Feb 3, 2023
0ef6bfd
build: use rollup-plugin-dts for dts build
yyx990803 Feb 3, 2023
73e3a2b
build: remove api-extractor
yyx990803 Feb 3, 2023
458f790
build: fix handling of const enum that rely on previous values
yyx990803 Feb 3, 2023
3271d73
ci: try puppeteer fix
yyx990803 Feb 3, 2023
943c336
build: adjust dts test setup
yyx990803 Feb 3, 2023
7197852
build: fix size check
yyx990803 Feb 3, 2023
970af3d
docs: update contributing guide
yyx990803 Feb 3, 2023
27c67e3
ci: avoid netlify oom
yyx990803 Feb 3, 2023
3b261e6
docs: document git hooks [ci skip]
yyx990803 Feb 3, 2023
bcc60e4
chore: use type: "module"
yyx990803 Feb 3, 2023
9be9909
chore: update packageManager field
yyx990803 Feb 3, 2023
feefb95
chore: use consistent ts-check comments in scripts
yyx990803 Feb 3, 2023
f103666
build: stricter conditions for UnaryExpression in const enum plugin
yyx990803 Feb 3, 2023
c2922ef
test: more strict linking in dts tests
yyx990803 Feb 3, 2023
da2c8d6
chore: use workspace vue dep for sfc-playground
yyx990803 Feb 3, 2023
a8a60a8
build: improve dts rollup output
yyx990803 Feb 4, 2023
0251d3e
release: v3.3.0-alpha.1
yyx990803 Feb 5, 2023
3ed730f
fix(build): fix dev flag replacement in esm-bundler builds
yyx990803 Feb 5, 2023
883dad2
chore: avoid double-building types on release
yyx990803 Feb 5, 2023
91d6f25
release: v3.3.0-alpha.2
yyx990803 Feb 5, 2023
59942f3
chore: catch unhandled export as just in case
yyx990803 Feb 6, 2023
d61f9c3
build: reuse const enum data between concurrent rollup builds
yyx990803 Feb 6, 2023
3dc6ca1
fix(build): avoid const enum conflicts
yyx990803 Feb 6, 2023
0e1351d
build: fix const enum when cache dir does not exist
yyx990803 Feb 6, 2023
06b4f19
release: v3.3.0-alpha.3
yyx990803 Feb 6, 2023
973465b
fix(build): fix const enum w/ number values
yyx990803 Feb 6, 2023
31fe690
release: v3.3.0-alpha.4
yyx990803 Feb 6, 2023
e2febe2
ci: add a ecosystem-ci-trigger workflow (#7618)
haoqunjiang Feb 10, 2023
074affa
chore: fix typo (#7680)
Alfred-Skyblue Feb 11, 2023
1644387
refactor(runtime-core): use Symbol.for for runtime Symbols
yyx990803 Feb 21, 2023
9b02e7b
chore: bump vitest + use threads
yyx990803 Feb 21, 2023
35d0ea8
fix(runtime-core): support `getCurrentInstance` across mutiple builds…
yyx990803 Feb 21, 2023
1bdbf2e
chore: remove warnings due to potential false-positives
yyx990803 Feb 21, 2023
6e0e5ec
ci: only disable threads for gh
yyx990803 Feb 21, 2023
88c0b04
ci: release canary versions every week (#7860)
haoqunjiang Mar 17, 2023
572c26b
build: fix canary bundling issues (#7907)
haoqunjiang Mar 17, 2023
427c286
refactor: remove circular dependencies in compiler
yyx990803 Mar 23, 2023
c636f81
build: bump rollup, remove cjs re-exports hack
yyx990803 Mar 23, 2023
318c2e8
chore: bump vite & vitest
yyx990803 Mar 23, 2023
622a794
build: upgrade to TypeScript 5.x
yyx990803 Mar 23, 2023
f173fc3
feat(dx): improve readability of displayed types for props
yyx990803 Mar 24, 2023
e911941
test: improve test case on `$el` (#7922)
himself65 Mar 25, 2023
7bca739
chore: add redirect for template explorer
yyx990803 Mar 26, 2023
71e31e3
fix(types): ensure defineProps with generics return correct types
yyx990803 Mar 26, 2023
83bf6af
chore: allow editing changelog before committing release
yyx990803 Mar 26, 2023
ce3f597
feat(types/jsx): support jsxImportSource, avoid global JSX conflict (…
yyx990803 Mar 26, 2023
9ca94fe
release: v3.3.0-alpha.5
yyx990803 Mar 26, 2023
dbe324a
fix(types/jsx): remove $slots children override
yyx990803 Mar 26, 2023
967afb3
chore: fix type
yyx990803 Mar 27, 2023
5154061
feat(types): `defineComponent()` with generics support (#7963)
yyx990803 Mar 27, 2023
3db4079
ci: avoid duplicated ci runs on self-repo pull requests
yyx990803 Mar 27, 2023
b5ff9a6
feat(sfc): deprecate reactivity transform
yyx990803 Mar 27, 2023
724a8e1
test: add test for defineComponent function syntax with object emits
yyx990803 Mar 28, 2023
4ff561f
build: don't wait for changelog edits when `--skip-prompts` or `--can…
haoqunjiang Mar 28, 2023
5ed39ab
build: exit with code 1 on release failure (#7962)
haoqunjiang Mar 28, 2023
92d7cb2
chore(deps): upgrade rollup & magic-string (#7326)
sxzz Mar 28, 2023
977232f
chore: remove unused deps
yyx990803 Mar 28, 2023
54b7f1b
chore: eslint node env should apply to root ts config files (#7687)
sxzz Mar 28, 2023
e793517
feat(compiler-sfc): add defineOptions macro (#5738)
sxzz Mar 28, 2023
bd84df4
fix(jsx-runtime): fix automatic runtime implementation (#7959)
remcohaszing Mar 28, 2023
d3fa878
fix(types): revert jsx global removal (to be removed in 3.4)
yyx990803 Mar 28, 2023
a502d7a
feat(complier-sfc): hoist literal constants for script (#5752)
sxzz Mar 28, 2023
199e313
fix(compiler-sfc): rewrite default export with AST analysis instead o…
sxzz Mar 28, 2023
2df2243
fix(compiler-sfc): infer function prop type from type literal w/ call…
sxzz Mar 28, 2023
3f8e1c3
fix(compiler-sfc): infer TS Extract&Exclude runtime type (#7339)
sxzz Mar 28, 2023
aa17992
fix(compiler-sfc): unwrap TS node for defineProps (#7340)
sxzz Mar 28, 2023
7ae4f2a
fix(compiler-sfc): infer TSIntersectionType in defineProps (#7394)
sxzz Mar 28, 2023
690a437
fix(compiler-sfc): handle more TS built-in utilities in defineProps i…
yyx990803 Mar 28, 2023
6b75125
fix(compiler-sfc): allow `<script>` with lang='js' (#7398)
sxzz Mar 28, 2023
0b9f820
fix(compiler-sfc): properly remove comma of multiple macros in the sa…
sxzz Mar 28, 2023
087dac0
fix(compiler-sfc): fix edge case of default export call with no args …
sxzz Mar 28, 2023
af06907
feat(compiler-sfc): support module string names syntax (#7428)
sxzz Mar 28, 2023
81e7cdb
fix(compiler-sfc): infer correct type for enums
yyx990803 Mar 28, 2023
f883df4
Revert "fix(compiler-sfc): infer correct type for enums"
yyx990803 Mar 28, 2023
dd09b4a
fix(compiler-sfc): properly handle unknown types in runtime prop infe…
yyx990803 Mar 28, 2023
830936a
feat(compiler-sfc): improve runtime props inference for enum
yyx990803 Mar 28, 2023
384ad47
feat(compiler-core): support parsing `const` modifier in type paramet…
sxzz Mar 28, 2023
5356663
fix(compiler-sfc): disallow `expose` property in `defineOptions` (#7967)
sxzz Mar 28, 2023
36da03b
fix(compiler-sfc): avoid codegen conflict with user variable named `e…
sxzz Mar 28, 2023
532be19
chore: update snapshots
yyx990803 Mar 28, 2023
bb2c98f
fix(compiler-sfc): use prependLeft to handle CSSVars (#7760)
baiwusanyu-c Mar 28, 2023
5502738
chore: update snapshots by #7766 (#7970)
baiwusanyu-c Mar 28, 2023
376ce19
chore: fix accidentally replaced comments [ci skip]
yyx990803 Mar 28, 2023
935609a
feat(runtime-core): add skipCheck for prop (#7548)
sxzz Mar 28, 2023
a166f25
fix(compiler-core): check if expression is constant (#7974)
sxzz Mar 29, 2023
c653a2d
fix(types/jsx): jsx-runtime types for global JSX namespace registrati…
haoqunjiang Mar 29, 2023
e843f99
fix(jsx-runtime): handle keys (#7976)
leopiccionia Mar 29, 2023
8525f8c
fix(types/jsx): move JSX DOM types back to `@vue/runtime-dom` (#7979)
haoqunjiang Mar 29, 2023
30f48fb
fix(compiler-sfc): fix defineExpose() codegen regression from #7949
yyx990803 Mar 29, 2023
45cb38f
fix(compiler-sfc): infer object type for empty type literal
yyx990803 Mar 29, 2023
72a5cef
fix(compiler-sfc): fix function default value handling w/ props destr…
yyx990803 Mar 29, 2023
38b15c0
feat(compiler-sfc): enable reactive props destructure by default and …
yyx990803 Mar 30, 2023
ae6c6b1
fix(compiler-sfc): infer runtime type in defineProps (#7972)
sxzz Mar 30, 2023
0d3ca0a
fix(compiler-core): fix codegen for literal const in non-inline mode
yyx990803 Mar 30, 2023
8143d84
feat(compiler-sfc): support generating variable instead of default ex…
yyx990803 Mar 30, 2023
63f3b12
build: improve dts generation
yyx990803 Mar 30, 2023
60c449b
chore: bump csstype version
yyx990803 Mar 30, 2023
b70f327
release: v3.3.0-alpha.6
yyx990803 Mar 30, 2023
0d3c75e
feat(sfc): support more ergnomic defineEmits type syntax (#7992)
yyx990803 Mar 30, 2023
d07d59f
feat(compiler-sfc): codegen support for defineEmits() short syntax (f…
yyx990803 Mar 30, 2023
f009170
refactor(compiler-sfc): remove unnecessary emits type codegen
yyx990803 Mar 30, 2023
fafa759
feat(sfc): revert withDefaults() deprecation
yyx990803 Mar 31, 2023
d9f7928
chore: remove unused param
yyx990803 Mar 31, 2023
6d665e3
feat(compiler-sfc): support arbitrary expression as withDefaults argu…
yyx990803 Mar 31, 2023
ea62511
fix(compiler-sfc): use dynamic defaults merging for methods with comp…
yyx990803 Mar 31, 2023
a22ff97
fix(compiler-dom): handle newlines when evaluating constants during s…
baiwusanyu-c Mar 31, 2023
4425409
docs: comments on reactivity functions (fixes #4832) (#4836)
defaude Mar 31, 2023
6cfd7b1
chore: add docs links for sfc macros
yyx990803 Apr 2, 2023
62a2b31
feat(reactivity): improve support of getter usage in reactivity APIs …
yyx990803 Apr 2, 2023
dc866cb
feat(types/slots): support slot presence / props type checks via `def…
sxzz Apr 3, 2023
cd5886d
release: v3.3.0-alpha.7
yyx990803 Apr 3, 2023
9aa7e55
fix(compiler-sfc): check binding is prop before erroring
yyx990803 Apr 4, 2023
00ef259
chore: add setupVitest to tsconfig (#8009)
JayFate Apr 4, 2023
4313480
chore: remove duplicate test (#8003)
wsypower Apr 4, 2023
cfeee77
release: v3.3.0-alpha.8
yyx990803 Apr 4, 2023
bf8282f
fix(compiler-ssr): disable v-once transform in ssr vdom fallback branch
yyx990803 Apr 5, 2023
c89fdf6
chore: remove unused args passed to ssrRender
yyx990803 Apr 5, 2023
b547ff3
feat(app): app.runWithContext() (#7451)
posva Apr 5, 2023
2ae405e
refactor(compiler-sfc): move related files into separate directories
yyx990803 Apr 5, 2023
5feb3dd
fix(types): improve defineProps return type with generic arguments
yyx990803 Apr 5, 2023
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
16 changes: 16 additions & 0 deletions packages/runtime-core/__tests__/hydration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,22 @@ describe('SSR hydration', () => {
expect((container.firstChild!.firstChild as any)._value).toBe(true)
})

test('hydrate custom element with vue bindings', () => {
class MyElement extends HTMLElement {
foo = ''
constructor() {
super()
}
}
customElements.define('my-element', MyElement)
const msg = ref('bar')
const { container } = mountWithHydration(
'<my-element :foo="msg"></my-element>',
() => h('my-element', { foo: msg.value })
)
expect((container.firstChild as any).foo).toBe(msg.value)
})

// #5728
test('empty text node in slot', () => {
const Comp = {
Expand Down
3 changes: 2 additions & 1 deletion packages/runtime-core/src/hydration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ export function createHydrationFunctions(
for (const key in props) {
if (
(forcePatchValue && key.endsWith('value')) ||
(isOn(key) && !isReservedProp(key))
(isOn(key) && !isReservedProp(key)) ||
customElements.get(el.localName) // If the element is a custom element, apply vue props during hydration - See #7203
Copy link
Member

@LinusBorg LinusBorg Dec 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to use the app config function like:

parentComponent.appContext.config.isCustomElement?.(el.localName)

That would be more desirable as we don't want to reference any DOM apis in runtime-core.

That check should also be done sooner, outside of the for loop.

This change would then also mean that we would have to append the docs for app.config.isCustomElement and explain that this function is not only useful when using the runtime Compiler, but also when using custom elements in an SSR app.

Copy link
Author

@steveworkman steveworkman Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the test app we're working with (nuxt 3) the isCustomElement function is always undefined, so we've not been able to use that function. The other functions in the appContext appear to be there. If you're certain that it should be there, I'll dig into where it goes missing some more

Copy link
Member

@LinusBorg LinusBorg Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My apologies, it's:

parentComponent.appContext.config.compilerOptions.isCustomElement?.(el.localName)

See https://vuejs.org/guide/extras/web-components.html#using-custom-elements-in-vue
https://vuejs.org/api/application.html#app-config-compileroptions

And of course, that function has to be added by the developer.

) {
patchProp(
el,
Expand Down