Commit Graph

584 Commits

Author SHA1 Message Date
Géry Debongnie cb107cef7d [REM] remove some outdated tests 2022-02-11 10:41:18 +01:00
Géry Debongnie e580ec00fe [REM] tests: remove async root tests 2022-02-11 10:41:18 +01:00
Lucas Perais (lpe) ee5f6c7569 [FIX] component: error_handling on current component
Have a Child Compnent which has one component that succeeds and another
one that fails at its instanciation.
The Child component handles the Errors by rendering itself.

Before this commit, the error handling algorithm made impossible for the scheduler to finish.
This was because the current fiber was still counted as ongoing, when it was actually completed.

After this commit, this use case is handled correctly.
2022-02-11 10:41:18 +01:00
Lucas Perais (lpe) b902edc1be [IMP] app, compiler: introduce t-out
t-out automatically escaped content when it is a string not marked
with the `markup` function

t-out renders the raw content if it is a Block, or if it has been marked
with the `markup` funtion.

t-esc has been kept since it is safe and is optimized to render text nodes.

all t-raw calls are in fact the same as t-out.
2022-02-11 10:41:18 +01:00
Lucas Perais (lpe) 1761af9c24 [FIX][BREAKING] t-esc on component is not supported anymore 2022-02-11 10:41:18 +01:00
Bruno Boi db93ef08ff [IMP] templates: can load multiple at once and also from XMLDocument 2022-02-11 10:41:18 +01:00
Mathieu Duckerts-Antoine 03787cfb39 [REF] reactivity: new API 2022-02-11 10:41:18 +01:00
Mathieu Duckerts-Antoine 10745c52d0 [REF] tests: remove debugger 2022-02-11 10:41:18 +01:00
Mathieu Duckerts-Antoine 2b90e3a688 [FIX] reactivity: memory leak
The deletion of a key in an observed object did clear the observers of
that key but did not clear the atoms created (if any) when the key existed
(e.g. on the key value if it was trackable). This can lead to a growing
set of atoms that are useless but kept in memory if a lot of keys are
added/deleted. The same thing can happen if a key value is changed many
times and the values are trackable.

Here we fix the problem by
- keeping tracks of the objects that have been observed by an external call
  to the method "atom" (we call them seeds).
- remove all observer atoms that are not seeds for observers of at least
  one key deletion or key value change.

Note the fix is in some sense partial: a user could use the "atom" primitive
making the new system uncapable of avoiding a leak (see test "atom on an
object with a getter 3" where a getter is used in a weird way in an
observed object).
2022-02-11 10:41:18 +01:00
Bruno Boi b2ea241270 [IMP] hooks: reintroduce useExternalListener 2022-02-11 10:41:18 +01:00
Bruno Boi 81e5b24f2f [IMP] hooks: introduce useEffect
Co-Authored-By: Samuel Degueldre <sad@odoo.com>
2022-02-11 10:41:18 +01:00
Bruno Boi 3fa1bb62f6 [IMP] env: env is now frozen, useSubEnv does not affect user env 2022-02-11 10:41:18 +01:00
Géry Debongnie 201f06c187 [FIX] tests: remove useless log 2022-02-11 10:41:18 +01:00
Géry Debongnie ae30d9db7d [FIX] portal: unskip some tests 2022-02-11 10:41:18 +01:00
Géry Debongnie af80cefa76 [FIX] component: fix lifecycle order 2022-02-11 10:41:18 +01:00
Géry Debongnie 1f6e84d141 [FIX] unskip tests 2022-02-11 10:41:18 +01:00
Géry Debongnie 1658d15b87 [REF] move event_bus into utils, readd 2 functions 2022-02-11 10:41:18 +01:00
Géry Debongnie c1439814bf [REM] tests: remove debug script tests 2022-02-11 10:41:18 +01:00
Géry Debongnie d5fbaff9f7 [REF] app: move TemplateSet into its own file 2022-02-11 10:41:18 +01:00
Géry Debongnie 8c16790471 [REF] move app and compiler code around 2022-02-11 10:41:18 +01:00
Géry Debongnie 1700a6fba3 [REF] compiler: rename qweb/ into compiler/ 2022-02-11 10:41:18 +01:00
Géry Debongnie 7513b1e507 [IMP] reactivity: slightly improve code and typing 2022-02-11 10:41:18 +01:00
Lucas Perais (lpe) e0c0306acd [IMP] component: re-introduce error handling in lifecycle 2022-02-11 10:41:18 +01:00
Samuel Degueldre bca6afeb90 [IMP] qweb: turn handlers into function expressions only
For the sake of consistency with vanilla JS, and to allow some things
that were previously not possible.
2022-02-11 10:41:18 +01:00
Mathieu Duckerts-Antoine 756d32daa0 [IMP] reactivity: Context replacement
Aim to replace the abstraction "Context" from OWL 1 with the new primitives
"atom" and "useState":

- notification is done only after a batch of modifications.
- observers are notified at most once for a batch.
- an observer of type component is notified (and rerendered)
  only if it does not have an ancestor that has to be notified for the
  same batch of operations (anywhere in the web of references!).
- notification of components is done on all levels "simultaneously".

Co-authored-by: Aaron Bohy <aab@odoo.com>
Co-authored-by: Géry Debongnie <ged@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2022-02-11 10:41:18 +01:00
Samuel Degueldre 153f4379f4 [FIX] qweb: fix crash with ref an component in same slot 2022-02-11 10:41:18 +01:00
Samuel Degueldre 7ffb9afbd9 [FIX] qweb: fix crash when component only renders empty slot 2022-02-11 10:41:18 +01:00
Samuel Degueldre c03042b44d [IMP] qweb/components: remove t-ref on components
Refs to component expose a lot of implementation details that should be
private to parents. Parent to child communication should go through
props.
2022-02-11 10:41:18 +01:00
Bruno Boi df2d6b6a0e [IMP] qweb: reintroduce t-tag directive
will not be compatible with t-model directive !
2022-02-11 10:41:18 +01:00
Lucas Perais (lpe) 7c04cc425e [IMP] qweb: compiler: support t-key on node and component without t-foreach 2022-02-11 10:41:18 +01:00
Bruno Boi 16f1e2c237 [IMP] bdom: support multiple synthetic events on one node 2022-02-11 10:41:18 +01:00
Bruno Boi 8a84b5be56 [IMP] qweb/attributes: uncomment two tests
- textarea with t-att-value
- select with t-att-value
2022-02-11 10:41:18 +01:00
Bruno Boi 219923d752 [IMP] qweb: introduce t-model directive
supported modifiers: lazy, trim, number
2022-02-11 10:41:18 +01:00
Bruno Boi 348b505e5f [IMP] tags: reintroduce inline css tag
The CSS tag is useful to define a css stylesheet in the javascript file:
```js
class MyComponent extends Component {
  static template = xml`
        <div class="my-component">some template</div>
    `;
  static style = css`
    .my-component {
      color: red;
    }
  `;
}
```

The `css` tag registers internally the css information. Then, whenever the first instance of the component is created, will add a <style> tag to the document <head>.

Original commit in Owl v1: 953778dc5
2022-02-11 10:41:18 +01:00
Mathieu Duckerts-Antoine d3745e4e5f [IMP] reactivity: new primitives for reactivity
fine grained reactivity:

existing key in source changes --> only observer having read the key are notified

add/delete key in source changes --> all source observers are notified

Co-authored-by: Aaron Bohy <aab@odoo.com>
Co-authored-by: Géry Debongnie <ged@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2022-02-11 10:41:18 +01:00
Mathieu Duckerts-Antoine 80cb6b7a91 [REF] Code prettification 2022-02-11 10:41:18 +01:00
Lucas Perais (lpe) 4cceb239dd [IMP] qweb, blockdom, components: t-on with modifiers
supported modifiers: capture, prevent, stop, self.
2022-02-11 10:20:09 +01:00
Lucas Perais (lpe) 2ae0149adb [IMP] blockdom: t-on supports synthetic and native event handler
Synthetic handler is a sort of event delegation that allows placing
only one listener on the document to improve performance. It is an opt-in option.

Native listener places the listener on the node itself.
2022-02-11 10:20:09 +01:00
Lucas Perais (lpe) 3eb63452e7 [FIX] qweb, component: remove support for t-on on component node 2022-02-11 10:20:09 +01:00
Lucas Perais (lpe) 1296964ae2 [FIX] qweb: t-key in t-foreach is mandatory, throws otherwise 2022-02-11 10:20:09 +01:00
Bruno Boi c71db28bc6 [FIX] qweb: reintroduce test on t-debug 2022-02-11 10:20:09 +01:00
Mathieu Duckerts-Antoine a0b2551e4a [IMP] tests: component mounting
We re-add some tests for component mounting.
2022-02-11 10:20:09 +01:00
Mathieu Duckerts-Antoine ebd2e4324f [IMP] app: mount app in "first-child" position
We reintroduce the possibility to mount the app in first position in
a target. The option "self" has been dropped since it is now possible
for a component to have several top level nodes.
2022-02-11 10:20:09 +01:00
Mathieu Duckerts-Antoine a0e1af83ac [IMP] component: defaultProps application
We re-add the application of defaultProps. Note that the application
is done twice in dev mode.
2022-02-11 10:20:09 +01:00
Mathieu Duckerts-Antoine c16d8ed6de [IMP] component,qweb: props validation
We re-add the possibility to validate props when dev mode is active.
No change in the API right Now. The dev mode is activated via the
configure method of App class.
2022-02-11 10:20:09 +01:00
Samuel Degueldre 15e4c856da [FIX] component: correctly create a new node when previous is destroyed
Previously, when a component node had been created and destroyed, and
the corresponding component was then recreated, the destroyed node was
reused. This commit fixes that
2022-02-11 10:20:09 +01:00
Samuel Degueldre ced5d0f69f [IMP] *: re-add a bunch of tests 2022-02-11 10:20:09 +01:00
Mathieu Duckerts-Antoine b6eb4d009e [IMP] qweb: t-props directive
We reimplement the directive "t-props" and add some tests for it.
2022-02-11 10:20:09 +01:00
Géry Debongnie 8c71d99e5f [MOV] move lifecycle_hooks into component/ 2022-02-11 10:20:09 +01:00
Mathieu Duckerts-Antoine d7f3f4defe [FIX] qweb: re-add test on memory leak
Re-add test from 6e185f9.
2022-02-11 10:20:09 +01:00