Page MenuHomePhabricator

Update WVUI for Vue 3 compatibility
Closed, DeclinedPublic

Description

To make WVUI work well with code in various stages of being migrated to Vue 3, we should make sure it works both with the Vue 3 migration build in compatibility mode, and with compatibility mode disabled.

Issues discovered so far:

  • Avoid binding false to attributes, bind null or 'false' instead
    • WvuiToggleButton's aria-pressed attribute
    • WvuiCheckbox's aria-disabled attribute
  • class attribute no longer applies to root when inheritAttrs: false is used
    • WvuiInput uses this, but WvuiTypeaheadSearch sets class on it. This applies to the root now but will move to the <input> element, which could cause problems. We may need to set :class="$attrs.class" on the root element of WvuiInput. This only affects the z-index: 1 rule on hover so the breakage would be subtle.
  • The standard prop and event names for v-model changed from value and input in Vue 2 to modelValue and update:modelValue in Vue 3. We should work around this by setting model: { prop: 'modelValue', event: 'update:modelValue' } on all components that use accept v-model, and emitting the previous events for backwards compatibility in cases where codesearch finds that they were listened to. We should also check in codesearch that the prop names are unused (as they hopefully mostly are).
    • WvuiInput
    • WvuiCheckbox
    • WvuiRadio
    • WvuiDropdown
    • WvuiOptionsMenu
  • Vue.observable() should be replaced with Vue.reactive() from the composition API
    • WvuiCheckbox
  • Something about how WvuiCheckbox uses template refs doesn't work with the Vue 3 migration build: the focusInput method throws an error because input.value is undefined.

Event Timeline

Much worse news: v-model on checkboxes created in Vue 2-compiled render functions doesn't work at all in the Vue 3 migration build: it throws an error and doesn't update the binding. I think this means we will need to release a Vue 3 version of WVUI, and put it in MediaWiki at the same time as we update to the Vue 3 migration build.

Upon further investigation, it turns out the error in Vue is a red herring, and it not updating the binding is because of how we're using the composition API for wrappedModel. We can probably work around this.

I figured out what the problem was: WVUI embeds the composition API plugin, which causes problems when running under Vue 3 where there's a real composition API. I have working draft patches that externalize the composition API to fix this problem. I'll get them into reviewable shape tomorrow and submit them.

Because externalizing the composition API plugin also requires a change to ResourceLoader, I've also written an alternative patch that continues to bundle the plugin with WVUI but bypasses it when it detects that Vue 3 is being used.

Change 738467 had a related patch set uploaded (by Catrope; author: Catrope):

[mediawiki/core@master] vue: Add @vue/composition-api as an alias for vue-composition-api

https://gerrit.wikimedia.org/r/738467

Change 738470 had a related patch set uploaded (by Catrope; author: Catrope):

[wvui@master] build: Externalize the Vue composition API plugin

https://gerrit.wikimedia.org/r/738470

Change 738472 had a related patch set uploaded (by Catrope; author: Catrope):

[wvui@master] [DO NOT MERGE] build: Wrap the composition API plugin to disable it in Vue 3

https://gerrit.wikimedia.org/r/738472

I figured out what the problem was: WVUI embeds the composition API plugin, which causes problems when running under Vue 3 where there's a real composition API. I have working draft patches that externalize the composition API to fix this problem. I'll get them into reviewable shape tomorrow and submit them.

Because externalizing the composition API plugin also requires a change to ResourceLoader, I've also written an alternative patch that continues to bundle the plugin with WVUI but bypasses it when it detects that Vue 3 is being used.

Note also T284707: Treat @vue/composition-api as a peer dependency

Catrope added a subscriber: egardner.

Thanks for pointing that out! I had completely missed that task, and now I'm sorry that I missed it, because if we had done what @egardner proposed on that task when he proposed it 5 months ago, I could have saved myself some grief debugging these really strange v-model issues.

Sorry, that it came late. I had a memory flash about composition-api and WVUI this afternoon after reading your comments above and search immediately brought it up.

Change 738466 had a related patch set uploaded (by Krinkle; author: Catrope):

[mediawiki/core@master] resourceloader: Implement support for module aliases

https://gerrit.wikimedia.org/r/738466

Change 738466 abandoned by Catrope:

[mediawiki/core@master] resourceloader: Implement support for module aliases

Reason:

Abandoned in favor of https://gerrit.wikimedia.org/r/c/mediawiki/core/+/739340

https://gerrit.wikimedia.org/r/738466

Change 738467 abandoned by Catrope:

[mediawiki/core@master] vue: Add @vue/composition-api as an alias for vue-composition-api

Reason:

Superseded by https://gerrit.wikimedia.org/r/c/mediawiki/core/+/739341

https://gerrit.wikimedia.org/r/738467

Catrope closed this task as Declined.EditedNov 16 2021, 8:46 PM

I now think we shouldn't do this at all. Instead of trying to make WVUI work with non-compat Vue 3, we should just make it work with the Vue 3 migration build (T284707), and then deprecate WVUI and migrate from WVUI to Codex while we're still on the migration build, before we move to "real" (non-compat) Vue 3.

Change 738472 abandoned by Winston Sung:

[wvui@master] [DO NOT MERGE] build: Wrap the composition API plugin to disable it in Vue 3

Reason:

This project has been archived

https://gerrit.wikimedia.org/r/738472