Repository navigation
[IMP] owl: let Odoo override Owl without modifying it - #2075
Merged
Merged
Conversation
Before this commit, each scheduler binds processTasks in its constructor and gives that bound function to requestAnimationFrame, so a patch of Scheduler.prototype.processTasks made after the scheduler was created is never called. Odoo patches it in its waitUntilIdle test helper, and has to modify Owl for that. This commit looks processTasks up at each frame instead.
Before this commit, the `owl` global defined by the iife bundles holds the exports as getters generated by esbuild: assigning one is silently ignored (or throws in strict code). Odoo, which uses Owl through this global, overrides some of them, and has to modify the build for that. This commit replaces the global with a plain copy of the exports.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Odoo carries two modifications of Owl (on its migration branch) so that it can override parts of it. This PR makes them unnecessary.
Scheduler.processTaskscan be patched. Each scheduler binds processTasks in its constructor and gives that bound function to requestAnimationFrame, so a patch ofScheduler.prototype.processTasksmade after the scheduler was created is never called. Odoo patches it in its waitUntilIdle test helper. processTasks is now looked up at each frame.The exports of the iife bundle can be overridden. The
owlglobal defined byowl.iife.jsandowl.iife.min.jsholds the exports as getters generated by esbuild: assigning one is silently ignored (or throws in strict code). Odoo uses Owl through this global and overrides some of them. The build now replaces the global with a plain copy of the exports (owl = { ...owl };as a footer).Notes:
owl.iife.jsandowl.iife.min.jsas scripts in jsdom: before,owl.onWillStartis a getter and assigning it has no effect; after, it is a writable value, all 57 exports are there, and a component still mounts and updates through the global.export let). The ESM and CJS bundles are unchanged.