1585 Commits

Author SHA1 Message Date
Géry Debongnie 7fb166bd50 [FIX] component: protect against errors in onWillDestroy 2022-04-01 13:40:24 +02:00
Lucas Perais (lpe) decf42c742 [FIX] compiler, component: dynamic t-slot with scope
A little typo was preventing a dynamic t-slot with a scope
(`<t t-slot="{{ state.name }}" myScope="someValue" />`)
to work properly.

This commit corrects this.
2022-03-31 16:15:47 +02:00
Géry Debongnie 989b0d6709 [REF] improve children handling in components/fibers 2022-03-31 08:54:59 +02:00
Géry Debongnie 9b93521da4 [FIX] issue with delayed renders being left pending forever 2022-03-31 08:54:59 +02:00
Lucas Perais (lpe) de240b1ebc [FIX] compiler, components: allow empty slot
Before this commit, a t-set-slot that has no content was not even compiled, and thus not passed
to the component for which it has was defined

After this commit, we allow a t-set-slot to have no content (because it can have slot props)
2022-03-29 16:24:05 +02:00
Géry Debongnie 55dbc01a1b [REL] v2.0.0-beta-4
# v2.0.0-beta.4

- fix: useEffect properly handle errors in effect function
- imp: reactivity: add missing support for forEach method
- imp: component: add name property on nodes for debug purposes
- imp: component: emit warning when async hooks take too long
- fix: blockdom: t-att- correcltly sets the value to zero
- fix: reactivity: do not crash when reading reactive frozen objects
- fix: utils: fix calls to batched callback from within the callback
- imp: component: wait for parent rendering to be complete before rendering child
v2.0.0-beta-4
2022-03-29 15:49:50 +02:00
Géry Debongnie e3b1566943 [IMP] component: wait for parent rendering to be complete before doing child
This is a breaking semantic change.  With this commit, the UI is frozen
whenever owl is waiting for a parent to change

Also, this allows Owl not to render components that will be removed
later.
2022-03-29 15:45:27 +02:00
Géry Debongnie 828be28653 [REF] component: introduce RootFiber.setCounter and update scheduler
The goal is to be able to execute code whenever a root fiber is ready,
and before the next animation frame
2022-03-29 15:45:27 +02:00
Samuel Degueldre d80fad760c [FIX] utils: fix calls to batched callback from within the callback
Previously, calling the batched function from within the callback being
batched would fail as it would be treated as part of the same batch.
This commit fixes that by scheduling the reset of the "called" flag
before calling the callback. This means that all microtasks that were
already in the microtask queue when a batch is about to run are treated
as part of the batch, and all microtasks that will be added by the
callback are not.
2022-03-29 09:13:00 +02:00
Samuel Degueldre 7611ea6033 [FIX] reactivity: do not crash when reading reactive frozen objects
This crash was caused by the fact that Proxies *must* return the value of the
property on the target when that property is non-writeable and
non-configurable. Since the reactivity system always attempts to proxify the
value from the target, this crashes.

This commit fixes that by not proxifying such values. This however means that
from that point on, we have escaped the reactivity system and will not
subscribe to any changes in that object or its children.
2022-03-28 13:15:00 +02:00
NsL01 c7d515a6b3 [FIX] doc: fix minor errors in todo app tutorial 2022-03-25 10:34:00 +01:00
Samuel Degueldre d277039b14 [FIX] blockdom: t-att- correcltly sets the value to zero
In 3536f41f00 we added a fallback when setting a
property to a falsy value so that the property was set to the empty string. The
objective being to not get the string "undefined"/"null"/"false" as property
value. However, using t-att- to set a property to 0 is perfectly reasonable and
in fact quite common.
2022-03-18 14:24:54 +01:00
Samuel Degueldre 77ff5ee895 [IMP] component: emit warning when async hooks take too long
This commit adds a warning when an async hook
(onWillUpdateProps/onWillStart) takes longer than 3 seconds, as these
hooks block the rendering and patching of the application, it is rarely
desirable and often a sign of a deadlock. This warning will contain the
stack trace of the call to the hook to help in debugging.
2022-03-14 09:51:47 +01:00
Géry Debongnie 47c6d6cc3c [IMP] component: add name property on nodes for debug purposes
also, improves the implementation of subscriptions
2022-03-11 15:14:55 +01:00
Samuel Degueldre 0625b5883a [IMP] reactivity: add missing support for forEach method 2022-03-11 14:02:42 +01:00
Géry Debongnie 53ab54b1ec [FIX] useEffect: properly handle errors in effect function
Before this commit, if the effect function would throw, then the cleanup
function would not be properly assigned, which caused additional errors
later, when the cleanup code would try to call it.

closes #1149
2022-03-08 15:23:49 +01:00
Samuel Degueldre 4770b91faa [IMP] doc: document dev mode 2022-03-08 14:45:44 +01:00
Samuel Degueldre c356351de2 [REL] v2.0.0-beta.3
# 2.0.0-beta.3

- improve error message for tokenization errors
- fix a bug where errors during rendering were incorrectly reported
- add support for t-on on components and slots (t-slot and t-set-slot)
v2.0.0-beta.3
2022-03-08 12:47:36 +01:00
Géry Debongnie f04423da23 [FIX] playground: properly set dev flag in examples 2022-03-08 12:24:57 +01:00
Géry Debongnie b3062d29f1 [REF] parser: make AST definition more consistent 2022-03-08 12:24:57 +01:00
Géry Debongnie 56086242bb [IMP] compiler: add support for t-on- on t-slots and t-set-slots 2022-03-08 12:24:57 +01:00
Géry Debongnie 998ecbb337 [REF] compiler: introduce define helper, slightly refactor code 2022-03-08 12:24:57 +01:00
Géry Debongnie 50355e6a3d [IMP] component: add support for t-on on compnents 2022-03-08 12:24:57 +01:00
Samuel Degueldre 67f86a4ab8 [FIX] components: wrap onWillRender/onRendered hooks instead of renderFn
Previously, we were wrapping the entire renderFn in a try/catch, causing
errors during template execution to be caught and wrapped by
onWillRender/onRendered which is undesirable. Now we only wrap the hook
that's being registered.
2022-03-08 10:18:15 +01:00
Samuel Degueldre 14d2328c88 [IMP] compiler: improve error message for tokenization errors 2022-03-08 10:18:15 +01:00
Géry Debongnie e4fdd32f22 [REL] v2.0.0-beta.2
# 2.0.0-beta.2

- only log dev message once, instead of once per app
- add subscriptions getter in dev mode on component node
- fix: issue with missing renderings
- fix: env now preserves prototype chain
v2.0.0-beta.2
2022-03-03 16:21:57 +01:00
Géry Debongnie 8d1d0a2244 [FIX] app: make sure we maintain the correct prototype chain in env 2022-03-03 16:19:05 +01:00
Géry Debongnie 0457e5d4ed [FIX] component: missing renderings in some cases 2022-03-03 16:19:05 +01:00
Samuel Degueldre 8920b4b93a [IMP] component, reactivity: add subscription getter in dev mode
This allows to see which objects and which keys in those objects a
component is observing, so that issues with missing renders or extra
renders can be more easily diagnosed.
2022-03-03 10:33:39 +01:00
Géry Debongnie 6908102a72 [IMP] app: only log dev message once
Before this commit, it was logged for every app created, which is
annoying in odoo: because of the compatibility layer, there are many
apps being created.
2022-03-03 08:48:37 +01:00
Géry Debongnie d6348b8310 [REL] v2.0.0-beta.1
# 2.0.0-beta.1

First beta release! The last missing feature has been merged (support for
sets/maps/weakmaps in the reactivity system).
v2.0.0-beta.1
2022-03-02 13:28:50 +01:00
Géry Debongnie 79738e00c7 [REF] small cleanup for template helpers 2022-03-02 13:26:22 +01:00
Géry Debongnie 2a1b99be2d [REM] remove the Memo component
With the new fine grained reactivity system, it was no longer useful.
2022-03-02 13:26:22 +01:00
Géry Debongnie 8a472231cf [FIX] release script was using a hardcoded value for notes
instead of the value that was actually provided by the user
2022-03-02 13:26:22 +01:00
Géry Debongnie bb373e6a7a [DOC] add explanation on structure of compiled template 2022-03-01 15:46:09 +01:00
Samuel Degueldre d735213758 [IMP] reactivity: add support for collections (Set/Map WeakSet/WeakMap) 2022-02-28 15:43:41 +01:00
Géry Debongnie 076b0d774e [REL] v2.0.0-alpha.3
# v2.0.0-alpha.3

A new release, with the fine grained reactivity applied to component props,
and changes in the way Owl render subcomponents: it can now skip patching and
or rendering child components if needed.
v2.0.0-alpha.3
2022-02-25 10:57:25 +01:00
Géry Debongnie f405fe9323 [DOC] add information about reactivity 2022-02-25 10:32:25 +01:00
Géry Debongnie 1ae9d514b9 [IMP] component: use reactivity to allow shallow renderings
With this commit, component only render child
components if they have different props (shallow
equality). Otherwise, we trust the reactivity
system to make sure that all impacted components
are updated
2022-02-25 10:32:25 +01:00
Géry Debongnie 592d9a458e [REF] move useState into component_node.ts 2022-02-25 10:32:25 +01:00
Géry Debongnie 0dbd2bd463 [REF] component: slightly simplify fiber code 2022-02-18 16:21:34 +01:00
Géry Debongnie 8ec7a6f9bf [FIX] compiler: prevent block- attributes and tags 2022-02-16 17:32:59 +01:00
Géry Debongnie 12b8ce963e [IMP] reactivity: toRaw now works with non reactive objects 2022-02-16 09:35:36 +01:00
Géry Debongnie bb9d65e95b [IMP] app: better error message when missing template 2022-02-16 09:35:36 +01:00
Géry Debongnie 73c339fff1 [DOC] remove outdated event bus doc 2022-02-15 10:31:03 +01:00
Géry Debongnie 406be446a5 [FIX] app: display correct url in dev mode message
closes #850
2022-02-15 10:15:07 +01:00
Géry Debongnie bd2aa8a72f [MISC] playground: improve benchmarking code 2022-02-15 09:07:32 +01:00
Géry Debongnie 3536f41f00 [FIX] blockdom: undefined properties are treated as empty strings 2022-02-15 09:07:32 +01:00
Samuel Degueldre 804ad3c35e [IMP] component: improve errors when thrown from lifecycle hooks
Previously, a crash in a lifecycle hook for any reason would throw an
error whose stack trace started from the scheduler and contained only
the place where the hook was called by owl, but not the place where the
hook was registered by the user. This proved very difficult for users to
debug as they cannot really tell which component registered that hook.

This commit alleviates the issue by creating a new Error when the hook
is originally called, and wrapping the registered callback in a try
catch, throwing an error with the correct stack trace instead of the
error in the hook, and setting the error in the hook as the cause of
this synthetic error.
2022-02-14 13:54:17 +01:00
Géry Debongnie 4a922ed82d [REL] v2.0.0-alpha.2
# v2.0.0-alpha.2

A new release, with some small fixes. Owl 2.0 is getting close.
v2.0.0-alpha.2
2022-02-14 13:42:34 +01:00