Commit Graph

1254 Commits

Author SHA1 Message Date
Géry Debongnie 8169f05edc [IMP] pin prettier version to ensure consistent results 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
Bruno Boi aa3148eddf [IMP] package.json: add watch arg to test:debug command
Before this commit
The command "npm run test:debug" runs the tests once.

After this commit
Jest runs in watch mode
2022-02-11 10:20:09 +01:00
Bruno Boi 42811344da [IMP] package.json: add remote test:debug command
Usage:
Open chrome://inspect then run in console:
> npm run test:debug ./path/to/your/testfile.ts
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
Mathieu Duckerts-Antoine 0f2192604c [FIX] qweb: t-set directive
This commit reintroduces some tests for the t-set directive and make
them pass. For that, it was necessary to adapt the qweb compiler in
order to get the following behaviors:

A t-set can affect parent contexts (up to the first parent tagged as
boundary) when the key changed is found in one of the parent contexts.
Some context are marked as boundaries in such a way that

   - rendering contexts (e.g. components) cannot be modified via a t-set.
   - a t-set in a t-call body or in a called template can never change a
     context above the t-call context.

Code prettification has been done.
Snapshots have been modified.
2022-02-11 10:19:44 +01:00
Lucas Perais (lpe) 10df0b5f4a [FIX] re-introduce tests 2022-02-11 10:19:44 +01:00
Mathieu Duckerts-Antoine d569ea1c28 [IMP] qweb: throw error when t-component is not used with a 't' tag 2022-02-11 10:19:44 +01:00
Lucas Perais (lpe) 52fa81c510 [FIX] re-introduce some missing tests
The point is to have visibility on the development of the owl2 features.
This commit reintroduces some tests keeping them skipped in order to fulfill that purpose.

There still are some missing tests though.
2022-02-11 10:18:03 +01:00
Mathieu Duckerts-Antoine d6668e3439 [IMP] qweb: re-add support of t-on directive
We add some test for the t-on directive.

For making them pass, it was necessary to change the code produced by
compileTForeach: the const declaration is not done by using generateId
and there was some conflict with the variable names produced in
captureExpression. Consequently, many snapshots had to be changed.

Code prettification has been done too.
2022-02-11 10:18:03 +01:00
Mathieu Duckerts-Antoine ee1ef20ce1 [ADD] components: re-add a test for t-foreach directive 2022-02-11 10:18:03 +01:00
Samuel Degueldre 9d5ffe11c7 [IMP] components: re-add a bunch of components tests from owl 1
Some tests are skipped because they rely on not-yet-implemented
features.
2022-02-11 10:18:03 +01:00
Samuel Degueldre 900a3ee501 [IMP] components: add back style_class tests
The tests have been adapted to the new way of doing things, some tests
are skipped because they rely on features that are not implemented yet
2022-02-11 10:18:03 +01:00
Mathieu Duckerts-Antoine 0a544bd7e8 [ADD] Translation feature
This commit brings back the possibility to translate text nodes and
the attributes "label", "title", "placeholder", and "alt" in an app
configured with a suitable translation function.

It is also possible to deactivate translations under a node via
the directive t-translation="off".

For flexibility it is possible to define the list of translatable
attributes in the app.
2022-02-11 10:18:03 +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
Samuel Degueldre efa147fdab [REF] qweb: use native Node and Element instead of custom Dom types 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
Géry Debongnie c06049076a [FIX] qweb: renderToString should not escape twice text content
Since commit
https://github.com/odoo/owl/commit/b2f12a111524f37348b142ac248813f9cb25ca2e,
Owl escape text content twice. It seems that it was done to prevent
security issues, but without realizing that the standard t-esc method
already escapes.

closes #708
2021-12-14 15:21:37 +01:00
Samuel Degueldre bc04f727ac [REL] v1.4.10
#v1.4.10

- fix: make arrow function capture backwards-compatible
v1.4.10
2021-12-07 15:32:05 +01:00
Samuel Degueldre 0bc9573a8a [FIX] component: make arrow-function capture backwards compatible
When fixing the absence of capture for arrow functions passed as props,
we unintentionally introduced a breaking change: bare function calls in
the arrow functions used to be called  with the rendering context as
their this value and this was no longer the case.

This commit fixes that by intentionally not capturing the value of
functions that are called withing the arrow function.
2021-12-07 15:27:00 +01:00
Samuel Degueldre 73f94fba3f [REL] v1.4.9
# v1.4.9

- fix: correctly capture the scope of arrow functions passed as props
v1.4.9
2021-12-07 10:09:12 +01:00
Samuel Degueldre 7a16449724 [IMP] CI: make formatting check mandatory for ci check 2021-12-03 14:08:05 +01:00
Samuel Degueldre 718c765e3b [FIX] qweb: correctly capture the scope of arrow functions in props 2021-12-03 14:08:05 +01:00
Samuel Degueldre 150d620b8e [REF] run prettier 2021-12-03 14:08:05 +01:00
Géry Debongnie 307b936d01 [REL] v1.4.8
# v1.4.8

- fix: prevent crash in some rare cases
v1.4.8
2021-11-03 13:44:46 +01:00
Achraf (abz) 6950f8e628 [FIX] components/fiber: Call patch only if target is valid
Currently in some cases, adding an attachment via lognote creates a traceback.
Error : shouldPatch is true while `vnode` is not defined, so `patch()` failed
This is a hotfix correcting this problem by calling `patch()` only if `shouldPatch` is true **and** the `vnode` is set.

opw-2645203
2021-11-03 11:37:04 +01:00
Géry Debongnie 4e3b7c74da [REL] v1.4.7
v1.4.7

fix: memory leak in some templates
v1.4.7
2021-10-19 16:47:20 +02:00