Commit Graph

279 Commits

Author SHA1 Message Date
Florent Dardenne - dafl@odoo d27455e9f2 [IMP] doc: explicit useEffect first parameter
The `useEffect` has two parameters:
* The `effect` function
* The `computeDependencies` function

The `effect` function always take as parameters the result
 of the `computeDependencies` function.

Expliciting this allows to better understand the `useEffect`
behaviour and the following example in the doc:

```
useEffect(
    (el) => el && el.focus(),
    () => [ref.el]
  );
```
2022-09-09 20:24:56 +02:00
Florent Dardenne - dafl@odoo a5a6a592c1 [FIX] tutorial_todoapp: fix the final code mount issue
In app.js, `mount(Root, document.body, { dev: true, env });`  crash because `body` is not available yet.
Therefore, moving the script into the body fix the issue.
2022-09-08 13:30:38 +02:00
Géry Debongnie c7459ef87b [IMP] add support for t-call-context directive 2022-06-22 16:15:54 +02:00
Géry Debongnie 9c4c3e3b83 [IMP] validation: add support for value types
This commit add supports for value types in prop validation. To describe
a value V type, one has to simply write {value: V}.

Note that this commit also improves the validation typing.

closes #1198
closes #910
2022-06-15 08:56:44 +02:00
Géry Debongnie 385e118e58 [FIX] compiler: add support for #{...} in string interpolation 2022-06-08 10:54:30 +02:00
Géry Debongnie 1fc88f626f [IMP] slots: add support for t-props on slots props 2022-06-07 09:30:45 +02:00
Géry Debongnie 6dcdb77eab [DOC] add informations on how to compile templates ahead of time
This may help people stuck on issue #1195. Note that the tooling is
still quite rough.
2022-05-31 14:00:01 +02:00
Géry Debongnie 98b58b505b [IMP] app: add setting to warn if no static props object
This can be helpful to track components that miss a static prop
description.

closes #1191
2022-05-24 13:52:42 +02:00
Géry Debongnie 1fe0bf08b1 [IMP] misc: export the validate function
The props validation code is actually quite difficult to get right.
Also, it is sometimes useful to be able to validate an object against a
specified schema. Therefore, this commit exports the standalone validate
function as an utility function.
2022-05-24 13:52:42 +02:00
Samuel Degueldre 4c77132ae2 [IMP] component: only useState on props that are already reactive
Previously, components would automatically call useState on their props,
so that changes deeply within props would automatically cause the
component to be rendered. This can be useful when passing a piece of
state to children or descendants.

One problem with this is that all props implicitly become reactive, even
if the object that was passed as a props was not. The problem with that
being that since the original object is not reactive, any change made by
the parent will not go through the reactivity system and the children
won't be notified of the change, in essence, this reactive object is
essentially useless, while having a real cost: traversing reactive
objects creates more reactive objects, and those objects are all
proxies. This is expensive for basically no benefit, while also making
it more difficult to debug code that involves those objects.

This commit fixes that by only calling useState on objects that are
already reactive, allowing the usecase described in the first paragraph
without the drawbacks described in the second.
2022-05-18 08:46:27 +02:00
Géry Debongnie 114f21586e [DOC] doc: remove obsolete documentation on context
The Context api was retired in owl 2.0, but a documentation file was
kept alive. This commit removes it, to prevent confusion in the future.

Thanks zerone40 for the issue

closes #1180
2022-05-17 09:59:49 +02:00
Géry Debongnie 7d14db7d31 [FIX] component: strict check of deep argument truth value
With this commit, we make sure that the `render` method was explicitely
called with the deep === true argument, instead of assuming that it is a
boolean.  This prevents errors when some unrelated value is given to the
render method. This could happen in some cases, such as

useBus(someBus, 'someevent', this.render)

In that case, the `useBus` code would simply call the this.render with a
customevent, which would be considered truthy before, and not anymore
2022-04-11 10:58:44 +02:00
NsL01 c7d515a6b3 [FIX] doc: fix minor errors in todo app tutorial 2022-03-25 10:34:00 +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 4770b91faa [IMP] doc: document dev mode 2022-03-08 14:45:44 +01:00
Géry Debongnie 50355e6a3d [IMP] component: add support for t-on on compnents 2022-03-08 12:24:57 +01:00
Géry Debongnie bb373e6a7a [DOC] add explanation on structure of compiled template 2022-03-01 15:46:09 +01:00
Géry Debongnie f405fe9323 [DOC] add information about reactivity 2022-02-25 10:32:25 +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 73c339fff1 [DOC] remove outdated event bus doc 2022-02-15 10:31:03 +01:00
Géry Debongnie 3196b585fd [FIX] slots: process slot params/values like normal props 2022-02-11 10:46:44 +01:00
Géry Debongnie 1fb1d37e32 [IMP] props validation: cannot set default value on mandatory props 2022-02-11 10:46:44 +01:00
Géry Debongnie 2c1226d737 [IMP] compiler: translatableAttributes can be added/removed 2022-02-11 10:46:44 +01:00
Samuel Degueldre 140818b5f9 [IMP] compiler: allow to declare default slot scope on component 2022-02-11 10:46:44 +01:00
Géry Debongnie 722abd6d5f [IMP] app: introduce test mode
Same as `dev` mode, but without warning in console
2022-02-11 10:46:44 +01:00
Géry Debongnie aa95149997 [IMP] hooks: introduce useChildSubEnv and change useSubEnv 2022-02-11 10:46:44 +01:00
Géry Debongnie 979712f84e [DOC] fix error in slot documentation 2022-02-11 10:46:44 +01:00
Géry Debongnie a4d9aae9a7 [FIX] svg: allow path as root tag 2022-02-11 10:46:44 +01:00
Géry Debongnie 0a73154985 [IMP] reactivity: introduces markRaw and toRaw functions 2022-02-11 10:46:44 +01:00
Géry Debongnie ce8ddd1cbf [DOC] improve useEffect doc 2022-02-11 10:46:44 +01:00
Géry Debongnie 5a2c769eab [DOC] document synthetic events 2022-02-11 10:46:44 +01:00
Géry Debongnie dfd0dcedb8 [IMP] doc: add changelog to doc test, update changelog 2022-02-11 10:46:44 +01:00
Géry Debongnie 0d13c362d3 [DOC] remove reference to catchError, fix mistake in changelog 2022-02-11 10:46:44 +01:00
Géry Debongnie cfb6b9f958 [DOC] update translations page 2022-02-11 10:46:44 +01:00
Géry Debongnie 82f6923a21 [DOC] add more information to the slots page 2022-02-11 10:46:44 +01:00
Géry Debongnie 82c7c24438 [DOC] reorganize and update documentation to owl 2 2022-02-11 10:46:44 +01:00
Géry Debongnie 75ad0835e9 [DOC] update quick_start and how to test pages 2022-02-11 10:46:44 +01:00
Géry Debongnie 3d6a5eb828 [REM] doc: remove overview page 2022-02-11 10:46:44 +01:00
Géry Debongnie aceaeef8cc [DOC] update the tutorial todo app 2022-02-11 10:46:44 +01:00
Géry Debongnie 702fb3b253 [DOC] reorganize doc, unskip test, fix some links 2022-02-11 10:46:44 +01:00
Géry Debongnie eb2c41aa91 [REM] tools: remove benchmarks/debug script
They are either no longer relevant, or less useful than some
alternatives (such as the js framework benchmark project)
2022-02-11 10:41:18 +01:00
Samuel Degueldre 4415cc8932 [REF] doc: remove references to router and store
Owl 2 will not have a router or store implemented inside the library
2022-02-11 10:18:03 +01:00
Géry Debongnie e746574a1d [REF] initial prototype of owl 2 2022-02-11 10:18:01 +01:00
Samuel Degueldre 150d620b8e [REF] run prettier 2021-12-03 14:08:05 +01:00
Géry Debongnie c0a62dfd05 [DOC] clarify tutorial
The part about setting up the various files did not express clearly that
we need the iife file, not the cjs.
2021-09-21 09:36:15 +02:00
Géry Debongnie 27629cedfa [IMP] qweb: allow multiclasses in t-att-class object form
the low level method htmlelement.classList.add does not accept multiple
classes in one string, which is why, in owl, the expression

`<div t-att-class="{'a b c': value}" />`

did not work as one might expect. It is however very convenient in real
life templates, so this commit improve owl by adding support for this
feature.

closes #813
2021-07-05 10:09:23 +02:00
Géry Debongnie 7419c1982a [DOC] tags: add missing information
The example given in the tags page was misleading.

closes #884
2021-07-05 10:09:23 +02:00
Bishal Pun a8c8f6affe Update comparison.md 2021-07-03 07:27:47 +02:00