Skip to content

Commit ba6eb18

Browse files
committed
Don't attempt to hydrate the DOM
Currently broken in Vue, due to vuejs/core#5063 Bug: T318137 Change-Id: I8a12a78bf62cccf4e9d900e09d9b49f6f124f893
1 parent 7f519e5 commit ba6eb18

File tree

3 files changed

+9
-20
lines changed

3 files changed

+9
-20
lines changed

dist/wikibase.termbox.main.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/client/buildAndAttemptHydration.ts

+5-18
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,9 @@ export default async function buildAndAttemptHydration(
3434

3535
const app = await buildApp( termboxRequest, services, config );
3636

37-
// mount the app in the wrapper element,
38-
// hiding warnings and errors because we know the DOM won’t hydrate perfectly (T300176)
39-
/* eslint-disable no-console */
40-
app.config.warnHandler = () => undefined;
41-
const consoleError = console.error;
42-
console.error = ( ...args ) => {
43-
if ( args.length === 1 && args[ 0 ] === 'Hydration completed but contains mismatches.' ) {
44-
// ignore, Vue offers no way to hide this hard-coded warning
45-
} else {
46-
return consoleError( ...args );
47-
}
48-
};
49-
try {
50-
app.mount( wrapperElement );
51-
} finally {
52-
console.error = consoleError;
53-
}
54-
/* eslint-enable no-console */
37+
// T318137: Due to https://github.com/vuejs/core/issues/5063 we can't rely on
38+
// Vue's hydration (as of October 2022).
39+
wrapperElement.textContent = '';
40+
41+
app.mount( wrapperElement );
5542
}

tests/unit/client/buildAndAttemptHydration.spec.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ describe( 'buildAndAttemptHydration', () => {
7272
const wrapperElement = mockApp.mount.mock.calls[ 0 ][ 0 ] as HTMLElement;
7373
expect( wrapperElement.className ).toBe( 'wikibase-entitytermsview-wrapper' );
7474
expect( wrapperElement.parentElement ).toBe( outerElement );
75-
expect( rootElement.parentElement ).toBe( wrapperElement );
7675
expect( unrelatedElement.parentElement ).toBe( outerElement );
76+
// The root element is discarded, thus has neither a parent nor children
77+
expect( rootElement.parentElement ).toBeNull();
78+
expect( rootElement.childElementCount ).toBe( 0 );
7779
} );
7880
} );
7981

0 commit comments

Comments
 (0)