mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 21b07afb60 |
+1
-25
@@ -1,4 +1,4 @@
|
|||||||
# Changelog
|
# ChangeLog
|
||||||
|
|
||||||
This document contains an overview of all changes between Owl 1.x and
|
This document contains an overview of all changes between Owl 1.x and
|
||||||
Owl 2.x, with some pointers on how to update the code.
|
Owl 2.x, with some pointers on how to update the code.
|
||||||
@@ -61,7 +61,6 @@ removed after.
|
|||||||
- breaking: `env` is now frozen ([details](#28-env-is-now-frozen))
|
- breaking: `env` is now frozen ([details](#28-env-is-now-frozen))
|
||||||
- breaking: `t-ref` does not work on components ([details](#29-t-ref-does-not-work-on-component))
|
- breaking: `t-ref` does not work on components ([details](#29-t-ref-does-not-work-on-component))
|
||||||
- breaking: `t-on` does not accept expressions, only functions ([details](#30-t-on-does-not-accept-expressions-only-functions))
|
- breaking: `t-on` does not accept expressions, only functions ([details](#30-t-on-does-not-accept-expressions-only-functions))
|
||||||
- breaking: `renderToString` function on qweb has been removed ([details](#32-rendertostring-on-qweb-has-been-removed))
|
|
||||||
|
|
||||||
|
|
||||||
## Details/Rationale/Migration
|
## Details/Rationale/Migration
|
||||||
@@ -587,26 +586,3 @@ So, the following template works for components:
|
|||||||
<div>2</div>
|
<div>2</div>
|
||||||
hello
|
hello
|
||||||
```
|
```
|
||||||
|
|
||||||
### 32. `renderToString` on QWeb has been removed
|
|
||||||
|
|
||||||
Rationale: the `renderToString` function was a qweb method, which made sense because
|
|
||||||
the qweb instance knew all templates. But now, the closest analogy is the `App`
|
|
||||||
class, but it is not as convenient, since the `app` instance is no longer visible
|
|
||||||
to components (while before, `qweb` was in the environment).
|
|
||||||
|
|
||||||
Also, this can easily be done in userspace, by mounting a component in a div. For example:
|
|
||||||
|
|
||||||
```js
|
|
||||||
export async function renderToString(template, context) {
|
|
||||||
class C extends Component {
|
|
||||||
static template = template;
|
|
||||||
}
|
|
||||||
const div = document.createElement('div');
|
|
||||||
document.body.appendChild(div);
|
|
||||||
const component = await mount(C, div);
|
|
||||||
const result = div.innerHTML;
|
|
||||||
app.destroy();
|
|
||||||
div.remove();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<h1 align="center">🦉 <a href="https://odoo.github.io/owl/">Owl Framework</a> 🦉</h1>
|
<h1 align="center">🦉 <a href="https://odoo.github.io/owl/">OWL Framework</a> 🦉</h1>
|
||||||
|
|
||||||
[](https://www.gnu.org/licenses/lgpl-3.0)
|
[](https://www.gnu.org/licenses/lgpl-3.0)
|
||||||
[](https://badge.fury.io/js/@odoo%2Fowl)
|
[](https://badge.fury.io/js/@odoo%2Fowl)
|
||||||
@@ -6,12 +6,10 @@
|
|||||||
|
|
||||||
_Class based components with hooks, reactive state and concurrent mode_
|
_Class based components with hooks, reactive state and concurrent mode_
|
||||||
|
|
||||||
**Try it online!** you can experiment with the Owl framework in an online [playground](https://odoo.github.io/owl/playground).
|
|
||||||
|
|
||||||
## Project Overview
|
## Project Overview
|
||||||
|
|
||||||
The Odoo Web Library (Owl) is a smallish (~<20kb gzipped) UI framework built by
|
The Odoo Web Library (OWL) is a smallish (~<20kb gzipped) UI framework intended to
|
||||||
[Odoo](https://www.odoo.com/) for its products. Owl is a modern
|
be the basis for the [Odoo](https://www.odoo.com/) Web Client. Owl is a modern
|
||||||
framework, written in Typescript, taking the best ideas from React and Vue in a
|
framework, written in Typescript, taking the best ideas from React and Vue in a
|
||||||
simple and consistent way. Owl's main features are:
|
simple and consistent way. Owl's main features are:
|
||||||
|
|
||||||
@@ -19,26 +17,39 @@ simple and consistent way. Owl's main features are:
|
|||||||
- a reactivity system based on hooks,
|
- a reactivity system based on hooks,
|
||||||
- concurrent mode by default,
|
- concurrent mode by default,
|
||||||
|
|
||||||
Owl components are defined with ES6 classes and xml templates, uses an
|
Owl components are defined with ES6 classes, they use QWeb templates, an
|
||||||
underlying virtual DOM, integrates beautifully with hooks, and the rendering is
|
underlying virtual DOM, integrates beautifully with hooks, and the rendering is
|
||||||
asynchronous.
|
asynchronous.
|
||||||
|
|
||||||
Quick links:
|
**Try it online!** An online playground is available at
|
||||||
|
[https://odoo.github.io/owl/playground](https://odoo.github.io/owl/playground)
|
||||||
|
to let you experiment with the Owl framework. There are some code examples to
|
||||||
|
showcase some interesting features.
|
||||||
|
|
||||||
- [documentation](#documentation),
|
Owl is currently stable. Possible future changes are explained in the
|
||||||
- [changelog](CHANGELOG.md) (from Owl 1.x to 2.x),
|
[roadmap](roadmap.md).
|
||||||
- [playground](https://odoo.github.io/owl/playground)
|
|
||||||
|
## Why Owl?
|
||||||
|
|
||||||
|
Why did Odoo decide to make Yet Another Framework? This is really a question
|
||||||
|
that deserves [a long answer](doc/miscellaneous/why_owl.md). But in short, we believe that
|
||||||
|
while the current state of the art frameworks are excellent, they are not
|
||||||
|
optimized for our use case, and there is still room for something else.
|
||||||
|
|
||||||
|
If you are interested in a comparison with React or Vue, you will
|
||||||
|
find some more additional information [here](doc/miscellaneous/comparison.md).
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
Here is a short example to illustrate interactive components:
|
Here is a short example to illustrate interactive components:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const { Component, useState, mount, xml } = owl;
|
const { Component, useState, mount } = owl;
|
||||||
|
const { xml } = owl.tags;
|
||||||
|
|
||||||
class Counter extends Component {
|
class Counter extends Component {
|
||||||
static template = xml`
|
static template = xml`
|
||||||
<button t-on-click="() => state.value++">
|
<button t-on-click="state.value++">
|
||||||
Click Me! [<t t-esc="state.value"/>]
|
Click Me! [<t t-esc="state.value"/>]
|
||||||
</button>`;
|
</button>`;
|
||||||
|
|
||||||
@@ -55,7 +66,7 @@ class App extends Component {
|
|||||||
static components = { Counter };
|
static components = { Counter };
|
||||||
}
|
}
|
||||||
|
|
||||||
mount(App, document.body);
|
mount(App, { target: document.body });
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that the counter component is made reactive with the [`useState` hook](doc/reference/hooks.md#usestate).
|
Note that the counter component is made reactive with the [`useState` hook](doc/reference/hooks.md#usestate).
|
||||||
@@ -65,55 +76,41 @@ But this is not mandatory, many applications will load templates separately.
|
|||||||
More interesting examples can be found on the
|
More interesting examples can be found on the
|
||||||
[playground](https://odoo.github.io/owl/playground) application.
|
[playground](https://odoo.github.io/owl/playground) application.
|
||||||
|
|
||||||
|
## Design Principles
|
||||||
|
|
||||||
|
OWL is designed to be used in highly dynamic applications where changing
|
||||||
|
requirements are common and code needs to be maintained by large teams.
|
||||||
|
|
||||||
|
- **XML based**: templates are based on the XML format, which allows interesting
|
||||||
|
applications. For example, they could be stored in a database and modified
|
||||||
|
dynamically with `xpaths`.
|
||||||
|
- **templates compilation in the browser**: this may not be a good fit for all
|
||||||
|
applications, but if you need to generate dynamically user interfaces in the
|
||||||
|
browser, this is very powerful. For example, a generic form view component
|
||||||
|
could generate a specific form user interface for each various models, from a XML view.
|
||||||
|
- **no toolchain required**: this is extremely useful for some applications, if,
|
||||||
|
for various reasons (security/deployment/dynamic modules/specific assets tools),
|
||||||
|
it is not ok to use standard web tools based on `npm`.
|
||||||
|
|
||||||
|
Owl is not designed to be fast nor small (even though it is quite good on those
|
||||||
|
two topics). It is a no nonsense framework to build applications. There is only
|
||||||
|
one way to define components (with classes). There is no black magic. It just
|
||||||
|
works.
|
||||||
|
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
### Learning Owl
|
A complete documentation for Owl can be found here:
|
||||||
|
|
||||||
Are you new to Owl? This is the place to start!
|
- [Main documentation page](doc/readme.md).
|
||||||
|
|
||||||
- [Tutorial: create a TodoList application](doc/learning/tutorial_todoapp.md)
|
Some of the most important pages are:
|
||||||
|
|
||||||
|
- [Tutorial: TodoList application](doc/learning/tutorial_todoapp.md)
|
||||||
- [How to start an Owl project](doc/learning/quick_start.md)
|
- [How to start an Owl project](doc/learning/quick_start.md)
|
||||||
- [How to test Components](doc/learning/how_to_test.md)
|
- [QWeb templating language](doc/reference/qweb_templating_language.md)
|
||||||
- [How to write Single File Components](doc/learning/how_to_write_sfc.md)
|
|
||||||
|
|
||||||
### Reference
|
|
||||||
|
|
||||||
You will find here a complete reference of every feature, class or object
|
|
||||||
provided by Owl.
|
|
||||||
|
|
||||||
- [Animations](doc/reference/animations.md)
|
|
||||||
- [Browser](doc/reference/browser.md)
|
|
||||||
- [Component](doc/reference/component.md)
|
- [Component](doc/reference/component.md)
|
||||||
- [Content](doc/reference/content.md)
|
|
||||||
- [Concurrency Model](doc/reference/concurrency_model.md)
|
|
||||||
- [Configuration](doc/reference/config.md)
|
|
||||||
- [Context](doc/reference/context.md)
|
|
||||||
- [Environment](doc/reference/environment.md)
|
|
||||||
- [Event Bus](doc/reference/event_bus.md)
|
|
||||||
- [Event Handling](doc/reference/event_handling.md)
|
|
||||||
- [Error Handling](doc/reference/error_handling.md)
|
|
||||||
- [Hooks](doc/reference/hooks.md)
|
- [Hooks](doc/reference/hooks.md)
|
||||||
- [Mounting a component](doc/reference/mounting.md)
|
|
||||||
- [Miscellaneous Components](doc/reference/misc.md)
|
|
||||||
- [Observer](doc/reference/observer.md)
|
|
||||||
- [Props](doc/reference/props.md)
|
|
||||||
- [Props Validation](doc/reference/props_validation.md)
|
|
||||||
- [QWeb Templating Language](doc/reference/qweb_templating_language.md)
|
|
||||||
- [QWeb Engine](doc/reference/qweb_engine.md)
|
|
||||||
- [Slots](doc/reference/slots.md)
|
|
||||||
- [Tags](doc/reference/tags.md)
|
|
||||||
- [Utils](doc/reference/utils.md)
|
|
||||||
|
|
||||||
### Other Topics
|
|
||||||
|
|
||||||
This section provides miscellaneous document that explains some topics
|
|
||||||
which cannot be considered either a tutorial, or reference documentation.
|
|
||||||
|
|
||||||
- [Owl architecture: the Virtual DOM](doc/miscellaneous/vdom.md)
|
|
||||||
- [Owl architecture: the rendering pipeline](doc/miscellaneous/rendering.md)
|
|
||||||
- [Comparison with React/Vue](doc/miscellaneous/comparison.md)
|
|
||||||
- [Why did Odoo built Owl?](doc/miscellaneous/why_owl.md)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Installing Owl
|
## Installing Owl
|
||||||
@@ -128,3 +125,6 @@ If you want to use a simple `<script>` tag, the last release can be downloaded h
|
|||||||
|
|
||||||
- [owl-1.4.7](https://github.com/odoo/owl/releases/tag/v1.4.7)
|
- [owl-1.4.7](https://github.com/odoo/owl/releases/tag/v1.4.7)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
OWL is [LGPL licensed](./LICENSE).
|
||||||
|
|||||||
+46
-11
@@ -30,21 +30,27 @@ To help with this, it is useful to have a `helper.js` file that contains some
|
|||||||
common utility functions:
|
common utility functions:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let lastFixture = null;
|
|
||||||
|
|
||||||
export function makeTestFixture() {
|
export function makeTestFixture() {
|
||||||
let fixture = document.createElement("div");
|
let fixture = document.createElement("div");
|
||||||
document.body.appendChild(fixture);
|
document.body.appendChild(fixture);
|
||||||
if (lastFixture) {
|
|
||||||
lastFixture.remove();
|
|
||||||
}
|
|
||||||
lastFixture = fixture;
|
|
||||||
return fixture;
|
return fixture;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function nextTick() {
|
export function nextTick() {
|
||||||
await new Promise((resolve) => setTimeout(resolve));
|
let requestAnimationFrame = owl.Component.scheduler.requestAnimationFrame;
|
||||||
await new Promise((resolve) => requestAnimationFrame(resolve));
|
return new Promise(function(resolve) {
|
||||||
|
setTimeout(() => requestAnimationFrame(() => resolve()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function makeTestEnv() {
|
||||||
|
// application specific. It needs a way to load actual templates
|
||||||
|
const templates = ...;
|
||||||
|
|
||||||
|
return {
|
||||||
|
qweb: new QWeb(templates),
|
||||||
|
..., // each service can be mocked here
|
||||||
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -53,7 +59,7 @@ With such a file, a typical test suite for Jest will look like this:
|
|||||||
```js
|
```js
|
||||||
// in SomeComponent.test.js
|
// in SomeComponent.test.js
|
||||||
import { SomeComponent } from "../../src/ui/SomeComponent";
|
import { SomeComponent } from "../../src/ui/SomeComponent";
|
||||||
import { nextTick, makeTestFixture } from '../helpers';
|
import { nextTick, makeTestFixture, makeTestEnv} from '../helpers';
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -64,6 +70,9 @@ let env: Env;
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = makeTestFixture();
|
fixture = makeTestFixture();
|
||||||
|
env = makeTestEnv();
|
||||||
|
// we set here the default environment for each component created in the test
|
||||||
|
Component.env = env;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@@ -76,7 +85,7 @@ afterEach(() => {
|
|||||||
describe("SomeComponent", () => {
|
describe("SomeComponent", () => {
|
||||||
test("component behaves as expected", async () => {
|
test("component behaves as expected", async () => {
|
||||||
const props = {...}; // depends on the component
|
const props = {...}; // depends on the component
|
||||||
const comp = await mount(SomeComponent, fixture, { props });
|
const comp = await mount(SomeComponent, { target: fixture, props });
|
||||||
|
|
||||||
// do some assertions
|
// do some assertions
|
||||||
expect(...).toBe(...);
|
expect(...).toBe(...);
|
||||||
@@ -93,3 +102,29 @@ describe("SomeComponent", () => {
|
|||||||
Note that Owl does wait for the next animation frame to actually update the DOM.
|
Note that Owl does wait for the next animation frame to actually update the DOM.
|
||||||
This is why it is necessary to wait with the `nextTick` (or other methods) to
|
This is why it is necessary to wait with the `nextTick` (or other methods) to
|
||||||
make sure that the DOM is up-to-date.
|
make sure that the DOM is up-to-date.
|
||||||
|
|
||||||
|
It is sometimes useful to wait until Owl is completely done updating components
|
||||||
|
(in particular, if we have a highly concurrent user interface). This next
|
||||||
|
helper simply polls every 20ms the internal Owl task queue and returns a promise
|
||||||
|
which resolves when it is empty:
|
||||||
|
|
||||||
|
```js
|
||||||
|
function afterUpdates() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let timer = setTimeout(poll, 20);
|
||||||
|
let counter = 0;
|
||||||
|
function poll() {
|
||||||
|
counter++;
|
||||||
|
if (owl.Component.scheduler.tasks.length) {
|
||||||
|
if (counter > 10) {
|
||||||
|
reject(new Error("timeout"));
|
||||||
|
} else {
|
||||||
|
timer = setTimeout(poll);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
# 🦉 Quick Overview 🦉
|
||||||
|
|
||||||
|
Owl components in an application are used to define a (dynamic) tree of components.
|
||||||
|
|
||||||
|
```
|
||||||
|
Root
|
||||||
|
/ \
|
||||||
|
A B
|
||||||
|
/ \
|
||||||
|
C D
|
||||||
|
```
|
||||||
|
|
||||||
|
**State:** each component can manage its own local state. It is a simple ES6
|
||||||
|
class, there are no special rules:
|
||||||
|
|
||||||
|
```js
|
||||||
|
class Counter extends Component {
|
||||||
|
static template = xml`
|
||||||
|
<button t-on-click="increment">
|
||||||
|
Click Me! [<t t-esc="state.value"/>]
|
||||||
|
</button>`;
|
||||||
|
|
||||||
|
state = { value: 0 };
|
||||||
|
|
||||||
|
increment() {
|
||||||
|
this.state.value++;
|
||||||
|
this.render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The example above shows a component with a local state. Note that since there
|
||||||
|
is nothing magical to the `state` object, we need to manually call the `render`
|
||||||
|
function whenever we update it. This can quickly become annoying (and not
|
||||||
|
efficient if we do it too much). There is a better way: using the `useState`
|
||||||
|
hook, which transforms an object into a reactive version of itself:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { useState } = owl.hooks;
|
||||||
|
|
||||||
|
class Counter extends Component {
|
||||||
|
static template = xml`
|
||||||
|
<button t-on-click="increment">
|
||||||
|
Click Me! [<t t-esc="state.value"/>]
|
||||||
|
</button>`;
|
||||||
|
|
||||||
|
state = useState({ value: 0 });
|
||||||
|
|
||||||
|
increment() {
|
||||||
|
this.state.value++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that the `t-on-click` handler can even be replaced by an inline statement:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<button t-on-click="state.value++">
|
||||||
|
```
|
||||||
|
|
||||||
|
**Props:** sub components often needs some information from their parents. This
|
||||||
|
is done by adding the required information to the template. This will then be
|
||||||
|
accessible by the sub component in the `props` object. Note that there is an
|
||||||
|
important rule here: the information contained in the `props` object is not
|
||||||
|
owned by the sub component, and should never be modified.
|
||||||
|
|
||||||
|
```js
|
||||||
|
class Child extends Component {
|
||||||
|
static template = xml`<div>Hello <t t-esc="props.name"/></div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Parent extends Component {
|
||||||
|
static template = xml`
|
||||||
|
<div>
|
||||||
|
<Child name="'Owl'" />
|
||||||
|
<Child name="'Framework'" />
|
||||||
|
</div>`;
|
||||||
|
static components = { Child };
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Communication:** there are multiple ways to communicate information between
|
||||||
|
components. However, the two most important ways are the following:
|
||||||
|
|
||||||
|
- from parent to children: by using `props`,
|
||||||
|
- from a children to one of its parent: by triggering events.
|
||||||
|
|
||||||
|
The following example illustrate both mechanisms:
|
||||||
|
|
||||||
|
```js
|
||||||
|
class OrderLine extends Component {
|
||||||
|
static template = xml`
|
||||||
|
<div t-on-click="add">
|
||||||
|
<div><t t-esc="props.line.name"/></div>
|
||||||
|
<div>Quantity: <t t-esc="props.line.quantity"/></div>
|
||||||
|
</div>`;
|
||||||
|
|
||||||
|
add() {
|
||||||
|
this.trigger("add-to-order", { line: this.props.line });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Parent extends Component {
|
||||||
|
static template = xml`
|
||||||
|
<div t-on-add-to-order="addToOrder">
|
||||||
|
<OrderLine
|
||||||
|
t-foreach="orders"
|
||||||
|
t-as="line"
|
||||||
|
line="line" />
|
||||||
|
</div>`;
|
||||||
|
static components = { OrderLine };
|
||||||
|
orders = useState([
|
||||||
|
{ id: 1, name: "Coffee", quantity: 0 },
|
||||||
|
{ id: 2, name: "Tea", quantity: 0 },
|
||||||
|
]);
|
||||||
|
|
||||||
|
addToOrder(event) {
|
||||||
|
const line = event.detail.line;
|
||||||
|
line.quantity++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
In this example, the `OrderLine` component trigger a `add-to-order` event. This
|
||||||
|
will generate a DOM event which will bubble along the DOM tree. It will then be
|
||||||
|
intercepted by the parent component, which will then get the line (from the
|
||||||
|
`detail` key) and then increment its quantity. See the page on [event handling](../reference/event_handling.md)
|
||||||
|
for more details on how events work.
|
||||||
|
|
||||||
|
Note that this example would have also worked if the `OrderLine` component
|
||||||
|
directly modifies the `line` object. However, this is not a good practice: this
|
||||||
|
only works because the `props` object received by the child component is reactive,
|
||||||
|
so the child component is then coupled to the parents implementation.
|
||||||
+47
-38
@@ -36,8 +36,6 @@ hello_owl/
|
|||||||
The file `owl.js` can be downloaded from the last release published at
|
The file `owl.js` can be downloaded from the last release published at
|
||||||
[https://github.com/odoo/owl/releases](https://github.com/odoo/owl/releases). It
|
[https://github.com/odoo/owl/releases](https://github.com/odoo/owl/releases). It
|
||||||
is a single javascript file which export all Owl into the global `owl` object.
|
is a single javascript file which export all Owl into the global `owl` object.
|
||||||
Note that there are multiple files, and in this case, we need one of the two
|
|
||||||
files suffixed with `.iife`: they are built to be directly used in a browser.
|
|
||||||
|
|
||||||
Now, `index.html` should contain the following:
|
Now, `index.html` should contain the following:
|
||||||
|
|
||||||
@@ -47,24 +45,30 @@ Now, `index.html` should contain the following:
|
|||||||
<head>
|
<head>
|
||||||
<title>Hello Owl</title>
|
<title>Hello Owl</title>
|
||||||
<script src="owl.js"></script>
|
<script src="owl.js"></script>
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script src="app.js"></script>
|
<script src="app.js"></script>
|
||||||
</body>
|
</head>
|
||||||
|
<body></body>
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
And `app.js` should look like this:
|
And `app.js` should look like this:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const { Component, mount, xml } = owl;
|
const { Component, mount } = owl;
|
||||||
|
const { xml } = owl.tags;
|
||||||
|
const { whenReady } = owl.utils;
|
||||||
|
|
||||||
// Owl Components
|
// Owl Components
|
||||||
class Root extends Component {
|
class App extends Component {
|
||||||
static template = xml`<div>Hello Owl</div>`;
|
static template = xml`<div>Hello Owl</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
mount(Root, document.body);
|
// Setup code
|
||||||
|
function setup() {
|
||||||
|
mount(App, target: { document.body })
|
||||||
|
}
|
||||||
|
|
||||||
|
whenReady(setup);
|
||||||
```
|
```
|
||||||
|
|
||||||
Now, simply loading this html file in a browser should display a welcome message.
|
Now, simply loading this html file in a browser should display a welcome message.
|
||||||
@@ -89,16 +93,14 @@ Let us start a new project with the following file structure:
|
|||||||
```
|
```
|
||||||
hello_owl/
|
hello_owl/
|
||||||
src/
|
src/
|
||||||
|
app.js
|
||||||
index.html
|
index.html
|
||||||
main.js
|
main.js
|
||||||
owl.js
|
owl.js
|
||||||
root.js
|
|
||||||
```
|
```
|
||||||
|
|
||||||
As previously, the file `owl.js` can be downloaded from the last release published at
|
As previously, the file `owl.js` can be downloaded from the last release published at
|
||||||
[https://github.com/odoo/owl/releases](https://github.com/odoo/owl/releases).
|
[https://github.com/odoo/owl/releases](https://github.com/odoo/owl/releases).
|
||||||
Note that there are multiple files, and in this case, we need one of the two
|
|
||||||
files suffixed with `.iife`: they are built to be directly used in a browser.
|
|
||||||
|
|
||||||
Now, `index.html` should contain the following:
|
Now, `index.html` should contain the following:
|
||||||
|
|
||||||
@@ -108,33 +110,37 @@ Now, `index.html` should contain the following:
|
|||||||
<head>
|
<head>
|
||||||
<title>Hello Owl</title>
|
<title>Hello Owl</title>
|
||||||
<script src="owl.js"></script>
|
<script src="owl.js"></script>
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script src="main.js" type="module"></script>
|
<script src="main.js" type="module"></script>
|
||||||
</body>
|
</head>
|
||||||
|
<body></body>
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
Not that the `main.js` script tag has the `type="module"` attribute. This means
|
Not that the `main.js` script tag has the `type="module"` attribute. This means
|
||||||
that the browser will parse the script as a module, and load all its dependencies.
|
that the browser will parse the script as a module, and load all its dependencies.
|
||||||
|
|
||||||
Here is the content of `root.js` and `main.js`:
|
Here is the content of `app.js` and `main.js`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// root.js ----------------------------------------------------------------------
|
// app.js ----------------------------------------------------------------------
|
||||||
const { Component, mount, xml } = owl;
|
const { Component, mount } = owl;
|
||||||
|
const { xml } = owl.tags;
|
||||||
|
|
||||||
export class Root extends Component {
|
export class App extends Component {
|
||||||
static template = xml`<div>Hello Owl</div>`;
|
static template = xml`<div>Hello Owl</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// main.js ---------------------------------------------------------------------
|
// main.js ---------------------------------------------------------------------
|
||||||
import { Root } from "./root.js";
|
import { App } from "./app.js";
|
||||||
|
|
||||||
mount(Root, document.body);
|
function setup() {
|
||||||
|
mount(App, { target: document.body });
|
||||||
|
}
|
||||||
|
|
||||||
|
owl.utils.whenReady(setup);
|
||||||
```
|
```
|
||||||
|
|
||||||
The `main.js` file imports the `root.js` file. Note that the import statement has
|
The `main.js` file import the `app.js` file. Note that the import statement has
|
||||||
a `.js` suffix, which is important. Most text editor can understand this syntax
|
a `.js` suffix, which is important. Most text editor can understand this syntax
|
||||||
and will provide autocompletion.
|
and will provide autocompletion.
|
||||||
|
|
||||||
@@ -187,11 +193,11 @@ hello_owl/
|
|||||||
index.html
|
index.html
|
||||||
src/
|
src/
|
||||||
components/
|
components/
|
||||||
Root.js
|
App.js
|
||||||
main.js
|
main.js
|
||||||
tests/
|
tests/
|
||||||
components/
|
components/
|
||||||
Root.test.js
|
App.test.js
|
||||||
helpers.js
|
helpers.js
|
||||||
.gitignore
|
.gitignore
|
||||||
package.json
|
package.json
|
||||||
@@ -218,15 +224,13 @@ Note that there are no `<script>` tag here. They will be injected by webpack.
|
|||||||
Now, let's have a look at the javascript files:
|
Now, let's have a look at the javascript files:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// src/components/Root.js -------------------------------------------------------
|
// src/components/App.js -------------------------------------------------------
|
||||||
import { Component, xml, useState } from "@odoo/owl";
|
import { Component, tags, useState } from "@odoo/owl";
|
||||||
|
|
||||||
export class Root extends Component {
|
const { xml } = tags;
|
||||||
static template = xml`
|
|
||||||
<div t-on-click="update">
|
|
||||||
Hello <t t-esc="state.text"/>
|
|
||||||
</div>`;
|
|
||||||
|
|
||||||
|
export class App extends Component {
|
||||||
|
static template = xml`<div t-on-click="update">Hello <t t-esc="state.text"/></div>`;
|
||||||
state = useState({ text: "Owl" });
|
state = useState({ text: "Owl" });
|
||||||
update() {
|
update() {
|
||||||
this.state.text = this.state.text === "Owl" ? "World" : "Owl";
|
this.state.text = this.state.text === "Owl" ? "World" : "Owl";
|
||||||
@@ -235,12 +239,16 @@ export class Root extends Component {
|
|||||||
|
|
||||||
// src/main.js -----------------------------------------------------------------
|
// src/main.js -----------------------------------------------------------------
|
||||||
import { utils, mount } from "@odoo/owl";
|
import { utils, mount } from "@odoo/owl";
|
||||||
import { Root } from "./components/Root";
|
import { App } from "./components/App";
|
||||||
|
|
||||||
mount(Root, document.body);
|
function setup() {
|
||||||
|
mount(App, { target: document.body });
|
||||||
|
}
|
||||||
|
|
||||||
// tests/components/Root.test.js ------------------------------------------------
|
utils.whenReady(setup);
|
||||||
import { Root } from "../../src/components/Root";
|
|
||||||
|
// tests/components/App.test.js ------------------------------------------------
|
||||||
|
import { App } from "../../src/components/App";
|
||||||
import { makeTestFixture, nextTick, click } from "../helpers";
|
import { makeTestFixture, nextTick, click } from "../helpers";
|
||||||
import { mount } from "@odoo/owl";
|
import { mount } from "@odoo/owl";
|
||||||
|
|
||||||
@@ -254,9 +262,9 @@ afterEach(() => {
|
|||||||
fixture.remove();
|
fixture.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Root", () => {
|
describe("App", () => {
|
||||||
test("Works as expected...", async () => {
|
test("Works as expected...", async () => {
|
||||||
await mount(Root, fixture);
|
await mount(App, { target: fixture });
|
||||||
expect(fixture.innerHTML).toBe("<div>Hello Owl</div>");
|
expect(fixture.innerHTML).toBe("<div>Hello Owl</div>");
|
||||||
|
|
||||||
click(fixture, "div");
|
click(fixture, "div");
|
||||||
@@ -270,8 +278,9 @@ import { Component } from "@odoo/owl";
|
|||||||
import "regenerator-runtime/runtime";
|
import "regenerator-runtime/runtime";
|
||||||
|
|
||||||
export async function nextTick() {
|
export async function nextTick() {
|
||||||
await new Promise((resolve) => setTimeout(resolve));
|
return new Promise(function (resolve) {
|
||||||
await new Promise((resolve) => requestAnimationFrame(resolve));
|
setTimeout(() => Component.scheduler.requestAnimationFrame(() => resolve()));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function makeTestFixture() {
|
export function makeTestFixture() {
|
||||||
|
|||||||
+319
-291
@@ -50,11 +50,10 @@ the following content:
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>OWL Todo App</title>
|
<title>OWL Todo App</title>
|
||||||
<link rel="stylesheet" href="app.css" />
|
<link rel="stylesheet" href="app.css" />
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script src="owl.js"></script>
|
<script src="owl.js"></script>
|
||||||
<script src="app.js"></script>
|
<script src="app.js"></script>
|
||||||
</body>
|
</head>
|
||||||
|
<body></body>
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -72,34 +71,44 @@ Note that we put everything inside an immediately executed function to avoid lea
|
|||||||
anything to the global scope.
|
anything to the global scope.
|
||||||
|
|
||||||
Finally, `owl.js` should be the last version downloaded from the Owl repository (you can use `owl.min.js` if you prefer). Be aware that you should download the `owl.iife.js` or `owl.iife.min.js`, because these files
|
Finally, `owl.js` should be the last version downloaded from the Owl repository (you can use `owl.min.js` if you prefer). Be aware that you should download the `owl.iife.js` or `owl.iife.min.js`, because these files
|
||||||
are built to run directly on the browser, and rename it `owl.js` (other files such as `owl.cjs.js` are
|
are built to run directly on the browser (other files such as `owl.cjs.js` are
|
||||||
built to be bundled by other tools).
|
built to be bundled by other tools).
|
||||||
|
|
||||||
Now, the project should be ready. Loading the `index.html` file into a browser
|
Now, the project should be ready. Loading the `index.html` file into a browser
|
||||||
should show an empty page, with the title `Owl Todo App`, and it should log a
|
should show an empty page, with the title `Owl Todo App`, and it should log a
|
||||||
message such as `hello owl 2.x.y` in the console.
|
message such as `hello owl 1.0.0` in the console.
|
||||||
|
|
||||||
## 2. Adding a first component
|
## 2. Adding a first component
|
||||||
|
|
||||||
An Owl application is made out of [components](../reference/component.md), with
|
An Owl application is made out of [components](../reference/component.md), with
|
||||||
a single root component. Let us start by defining a `Root` component. Replace the
|
a single root component. Let us start by defining an `App` component. Replace the
|
||||||
content of the function in `app.js` by the following code:
|
content of the function in `app.js` by the following code:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const { Component, mount, xml } = owl;
|
const { Component, mount } = owl;
|
||||||
|
const { xml } = owl.tags;
|
||||||
|
const { whenReady } = owl.utils;
|
||||||
|
|
||||||
// Owl Components
|
// Owl Components
|
||||||
class Root extends Component {
|
class App extends Component {
|
||||||
static template = xml`<div>todo app</div>`;
|
static template = xml`<div>todo app</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
mount(Root, document.body);
|
// Setup code
|
||||||
|
function setup() {
|
||||||
|
mount(App, { target: document.body });
|
||||||
|
}
|
||||||
|
|
||||||
|
whenReady(setup);
|
||||||
```
|
```
|
||||||
|
|
||||||
Now, reloading the page in a browser should display a message.
|
Now, reloading the page in a browser should display a message.
|
||||||
|
|
||||||
The code is pretty simple: we define a component with an inline template, then
|
The code is pretty simple, but let us explain the last line in more detail. The
|
||||||
mount it in the document body.
|
browser tries to execute the javascript code in `app.js` as quickly as possible,
|
||||||
|
and it could happen that the DOM is not ready yet when we try to mount the `App`
|
||||||
|
component. To avoid this situation, we use the [`whenReady`](../reference/utils.md#whenready)
|
||||||
|
helper to delay the execution of the `setup` function until the DOM is ready.
|
||||||
|
|
||||||
Note 1: in a larger project, we would split the code in multiple files, with
|
Note 1: in a larger project, we would split the code in multiple files, with
|
||||||
components in a sub folder, and a main file that would initialize the application.
|
components in a sub folder, and a main file that would initialize the application.
|
||||||
@@ -140,20 +149,20 @@ with the following keys:
|
|||||||
tasks. Since the title is something created/edited by the user, it offers
|
tasks. Since the title is something created/edited by the user, it offers
|
||||||
no guarantee that it is unique. So, we will generate a unique `id` number for
|
no guarantee that it is unique. So, we will generate a unique `id` number for
|
||||||
each task.
|
each task.
|
||||||
- `text`: a string, to explain what the task is about.
|
- `title`: a string, to explain what the task is about.
|
||||||
- `isCompleted`: a boolean, to keep track of the status of the task
|
- `isCompleted`: a boolean, to keep track of the status of the task
|
||||||
|
|
||||||
Now that we decided on the internal format of the state, let us add some demo
|
Now that we decided on the internal format of the state, let us add some demo
|
||||||
data and a template to the `App` component:
|
data and a template to the `App` component:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
class Root extends Component {
|
class App extends Component {
|
||||||
static template = xml/* xml */ `
|
static template = xml/* xml */ `
|
||||||
<div class="task-list">
|
<div class="task-list">
|
||||||
<t t-foreach="tasks" t-as="task" t-key="task.id">
|
<t t-foreach="tasks" t-as="task" t-key="task.id">
|
||||||
<div class="task">
|
<div class="task">
|
||||||
<input type="checkbox" t-att-checked="task.isCompleted"/>
|
<input type="checkbox" t-att-checked="task.isCompleted"/>
|
||||||
<span><t t-esc="task.text"/></span>
|
<span><t t-esc="task.title"/></span>
|
||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
</div>`;
|
</div>`;
|
||||||
@@ -161,12 +170,12 @@ class Root extends Component {
|
|||||||
tasks = [
|
tasks = [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
text: "buy milk",
|
title: "buy milk",
|
||||||
isCompleted: true,
|
isCompleted: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
text: "clean house",
|
title: "clean house",
|
||||||
isCompleted: false,
|
isCompleted: false,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -236,25 +245,29 @@ a little bit:
|
|||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Task Component
|
// Task Component
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
class Task extends Component {
|
const TASK_TEMPLATE = xml /* xml */`
|
||||||
static template = xml /* xml */`
|
|
||||||
<div class="task" t-att-class="props.task.isCompleted ? 'done' : ''">
|
<div class="task" t-att-class="props.task.isCompleted ? 'done' : ''">
|
||||||
<input type="checkbox" t-att-checked="props.task.isCompleted"/>
|
<input type="checkbox" t-att-checked="props.task.isCompleted"/>
|
||||||
<span><t t-esc="props.task.title"/></span>
|
<span><t t-esc="props.task.title"/></span>
|
||||||
</div>`;
|
</div>`;
|
||||||
static props = ["task"];
|
|
||||||
|
class Task extends Component {
|
||||||
|
static template = TASK_TEMPLATE;
|
||||||
|
static props = ["task"];
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Root Component
|
// App Component
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
class Root extends Component {
|
const APP_TEMPLATE = xml /* xml */`
|
||||||
static template = xml /* xml */`
|
|
||||||
<div class="task-list">
|
<div class="task-list">
|
||||||
<t t-foreach="tasks" t-as="task" t-key="task.id">
|
<t t-foreach="tasks" t-as="task" t-key="task.id">
|
||||||
<Task task="task"/>
|
<Task task="task"/>
|
||||||
</t>
|
</t>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
|
class App extends Component {
|
||||||
|
static template = APP_TEMPLATE;
|
||||||
static components = { Task };
|
static components = { Task };
|
||||||
|
|
||||||
tasks = [
|
tasks = [
|
||||||
@@ -263,9 +276,14 @@ class Root extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Setup
|
// Setup code
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
mount(Root, document.body, {dev: true});
|
function setup() {
|
||||||
|
owl.config.mode = "dev";
|
||||||
|
mount(App, { target: document.body });
|
||||||
|
}
|
||||||
|
|
||||||
|
whenReady(setup);
|
||||||
```
|
```
|
||||||
|
|
||||||
A lot of stuff happened here:
|
A lot of stuff happened here:
|
||||||
@@ -274,22 +292,24 @@ A lot of stuff happened here:
|
|||||||
- whenever we define a sub component, it needs to be added to the static
|
- whenever we define a sub component, it needs to be added to the static
|
||||||
[`components`](../reference/component.md#static-properties)
|
[`components`](../reference/component.md#static-properties)
|
||||||
key of its parent, so Owl can get a reference to it,
|
key of its parent, so Owl can get a reference to it,
|
||||||
|
- the templates have been extracted out of the components, to make it easier to
|
||||||
|
differentiate the "view/template" code from the "script/behavior" code,
|
||||||
- the `Task` component has a `props` key: this is only useful for validation
|
- the `Task` component has a `props` key: this is only useful for validation
|
||||||
purpose. It says that each `Task` should be given exactly one prop, named
|
purpose. It says that each `Task` should be given exactly one prop, named
|
||||||
`task`. If this is not the case, Owl will throw an
|
`task`. If this is not the case, Owl will throw an
|
||||||
[error](../reference/props_validation.md). This is extremely
|
[error](../reference/props_validation.md). This is extremely
|
||||||
useful when refactoring components
|
useful when refactoring components
|
||||||
- finally, to activate the props validation, we need to set Owl's
|
- finally, to activate the props validation, we need to set Owl's
|
||||||
[mode](../reference/config.md#mode) to `dev`. This is done in the last argument
|
[mode](../reference/config.md#mode) to `dev`. This is done in the `setup`
|
||||||
of the `mount` function. Note that this should be removed when an app is used in a real
|
function. Note that this should be removed when an app is used in a real
|
||||||
production environment, since `dev` mode is slightly slower, due to extra
|
production environment, since `dev` mode is slightly slower, due to extra
|
||||||
checks and validations.
|
checks and validations.
|
||||||
|
|
||||||
## 6. Adding tasks (part 1)
|
## 6. Adding tasks (part 1)
|
||||||
|
|
||||||
We still use a list of hardcoded tasks. It's really time to give the user a way
|
We still use a list of hardcoded tasks. It's really time to give the user a way
|
||||||
to add tasks himself. The first step is to add an input to the `Root` component.
|
to add tasks himself. The first step is to add an input to the `App` component.
|
||||||
But this input will be outside of the task list, so we need to adapt `Root`
|
But this input will be outside of the task list, so we need to adapt `App`
|
||||||
template, js, and css:
|
template, js, and css:
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
@@ -307,9 +327,9 @@ template, js, and css:
|
|||||||
addTask(ev) {
|
addTask(ev) {
|
||||||
// 13 is keycode for ENTER
|
// 13 is keycode for ENTER
|
||||||
if (ev.keyCode === 13) {
|
if (ev.keyCode === 13) {
|
||||||
const text = ev.target.value.trim();
|
const title = ev.target.value.trim();
|
||||||
ev.target.value = "";
|
ev.target.value = "";
|
||||||
console.log('adding task', text);
|
console.log('adding task', title);
|
||||||
// todo
|
// todo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -338,9 +358,10 @@ task. Notice that when you load the page, the input is not focused. But adding
|
|||||||
tasks is a core feature of a task list, so let us make it as fast as possible by
|
tasks is a core feature of a task list, so let us make it as fast as possible by
|
||||||
focusing the input.
|
focusing the input.
|
||||||
|
|
||||||
We need to execute code when the `Root` component is ready (mounted). Let's do
|
Since `App` is a component, it has a
|
||||||
that using the `onMounted` hook. We will also need to get a reference to the
|
[`mounted` lifecycle method](../reference/component.md#lifecycle) that we can
|
||||||
input, by using the `t-ref` directive with the [`useRef`](../reference/hooks.md#useref) hook:
|
implement. We will also need to get a reference to the input, by using the
|
||||||
|
`t-ref` directive with the [`useRef`](../reference/hooks.md#useref) hook:
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<input placeholder="Enter a new task" t-on-keyup="addTask" t-ref="add-input"/>
|
<input placeholder="Enter a new task" t-on-keyup="addTask" t-ref="add-input"/>
|
||||||
@@ -348,21 +369,22 @@ input, by using the `t-ref` directive with the [`useRef`](../reference/hooks.md#
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
// on top of file:
|
// on top of file:
|
||||||
const { Component, mount, xml, useRef, onMounted } = owl;
|
const { useRef } = owl.hooks;
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// in App
|
// in App
|
||||||
setup() {
|
inputRef = useRef("add-input");
|
||||||
const inputRef = useRef("add-input");
|
|
||||||
onMounted(() => inputRef.el.focus());
|
mounted() {
|
||||||
|
this.inputRef.el.focus();
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
This is a very common situation: whenever we need to perform some actions depending
|
The `inputRef` is defined as a class field, so it is equivalent to defining it
|
||||||
on the lifecycle of a component, we need to do it in the `setup` method, by using
|
in the constructor. It simply instructs Owl to keep a reference to anything with
|
||||||
one of the lifecycle hook. Here, we first get a reference to the `inputRef`,
|
the corresponding `t-ref` keyword. We then implement the `mounted` lifecycle
|
||||||
then in the `onMounted` hook, we simply focus the html element.
|
method, where we now have an active reference that we can use to focus the input.
|
||||||
|
|
||||||
## 7. Adding tasks (part 2)
|
## 7. Adding tasks (part 2)
|
||||||
|
|
||||||
@@ -383,12 +405,12 @@ Now, the `addTask` method can be implemented:
|
|||||||
addTask(ev) {
|
addTask(ev) {
|
||||||
// 13 is keycode for ENTER
|
// 13 is keycode for ENTER
|
||||||
if (ev.keyCode === 13) {
|
if (ev.keyCode === 13) {
|
||||||
const text = ev.target.value.trim();
|
const title = ev.target.value.trim();
|
||||||
ev.target.value = "";
|
ev.target.value = "";
|
||||||
if (text) {
|
if (title) {
|
||||||
const newTask = {
|
const newTask = {
|
||||||
id: this.nextId++,
|
id: this.nextId++,
|
||||||
text: text,
|
title: title,
|
||||||
isCompleted: false,
|
isCompleted: false,
|
||||||
};
|
};
|
||||||
this.tasks.push(newTask);
|
this.tasks.push(newTask);
|
||||||
@@ -406,7 +428,7 @@ the user interface. We can fix the issue by making `tasks` reactive, with the
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
// on top of the file
|
// on top of the file
|
||||||
const { Component, mount, xml, useRef, onMounted, useState } = owl;
|
const { useRef, useState } = owl.hooks;
|
||||||
|
|
||||||
// replace the task definition in App with the following:
|
// replace the task definition in App with the following:
|
||||||
tasks = useState([]);
|
tasks = useState([]);
|
||||||
@@ -421,8 +443,12 @@ did not change in opacity. This is because there is no code to modify the
|
|||||||
`isCompleted` flag.
|
`isCompleted` flag.
|
||||||
|
|
||||||
Now, this is an interesting situation: the task is displayed by the `Task`
|
Now, this is an interesting situation: the task is displayed by the `Task`
|
||||||
component, but it is not the owner of its state, so ideally, it should not modify it.
|
component, but it is not the owner of its state, so it cannot modify it. Instead,
|
||||||
However, for now, that's what we will do (this will be improved in a later step).
|
we want to communicate the request to toggle a task to the `App` component.
|
||||||
|
Since `App` is a parent of `Task`, we can
|
||||||
|
[trigger](../reference/event_handling.md) an event in `Task` and listen
|
||||||
|
for it in `App`.
|
||||||
|
|
||||||
In `Task`, change the `input` to:
|
In `Task`, change the `input` to:
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
@@ -433,23 +459,36 @@ and add the `toggleTask` method:
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
toggleTask() {
|
toggleTask() {
|
||||||
this.props.task.isCompleted = !this.props.task.isCompleted;
|
this.trigger('toggle-task', {id: this.props.task.id});
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
We now need to listen for that event in the `App` template:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<div class="task-list" t-on-toggle-task="toggleTask">
|
||||||
|
```
|
||||||
|
|
||||||
|
and implement the `toggleTask` code:
|
||||||
|
|
||||||
|
```js
|
||||||
|
toggleTask(ev) {
|
||||||
|
const task = this.tasks.find(t => t.id === ev.detail.id);
|
||||||
|
task.isCompleted = !task.isCompleted;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## 9. Deleting tasks
|
## 9. Deleting tasks
|
||||||
|
|
||||||
Let us now add the possibility do delete tasks. This is different from the previous
|
Let us now add the possibility do delete tasks. To do that, we first need to add
|
||||||
feature: deleting task has to be done on the task itself, but the actual operation
|
a trash icon on each task, then we will proceed just like in the previous section.
|
||||||
need to be done on the task list. So, we need to communicate the request to the
|
|
||||||
`Root` component. This is usually done by providing a callback in a prop.
|
|
||||||
|
|
||||||
First, let us update the `Task` template, css and js:
|
First, let us update the `Task` template, css and js:
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<div class="task" t-att-class="props.task.isCompleted ? 'done' : ''">
|
<div class="task" t-att-class="props.task.isCompleted ? 'done' : ''">
|
||||||
<input type="checkbox" t-att-checked="props.task.isCompleted" t-on-click="toggleTask"/>
|
<input type="checkbox" t-att-checked="props.task.isCompleted" t-on-click="toggleTask"/>
|
||||||
<span><t t-esc="props.task.text"/></span>
|
<span><t t-esc="props.task.title"/></span>
|
||||||
<span class="delete" t-on-click="deleteTask">🗑</span>
|
<span class="delete" t-on-click="deleteTask">🗑</span>
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
@@ -478,226 +517,218 @@ First, let us update the `Task` template, css and js:
|
|||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
static props = ["task", "onDelete"];
|
|
||||||
|
|
||||||
deleteTask() {
|
deleteTask() {
|
||||||
this.props.onDelete(this.props.task);
|
this.trigger('delete-task', {id: this.props.task.id});
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
And now, we need to provide the `onDelete` callback to each tasks in the `Root`
|
And now, we need to listen to the `delete-task` event in `App`:
|
||||||
component:
|
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<Task task="task" onDelete.bind="deleteTask"/>
|
<div class="task-list" t-on-toggle-task="toggleTask" t-on-delete-task="deleteTask">
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
deleteTask(task) {
|
deleteTask(ev) {
|
||||||
const index = this.tasks.findIndex(t => t.id === task.id);
|
const index = this.tasks.findIndex(t => t.id === ev.detail.id);
|
||||||
this.tasks.splice(index, 1);
|
this.tasks.splice(index, 1);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Notice that the `onDelete` prop is defined with a `.bind` suffix: this is a special
|
|
||||||
suffix that makes sure the function callback is bound to the component.
|
|
||||||
|
|
||||||
## 10. Using a store
|
## 10. Using a store
|
||||||
|
|
||||||
Looking at the code, it is apparent that all the code handling tasks is scattered
|
Looking at the code, it is apparent that we now have code to handle tasks
|
||||||
all around the application. Also, it mixes UI code and business logic
|
scattered in more than one place. Also, it mixes UI code and business logic
|
||||||
code. Owl does not provide any high level abstraction to manage business logic,
|
code. Owl has a way to manage state separately from the user interface: a
|
||||||
but it is easy to do it with the basic reactivity primitives (`useState` and `reactive`).
|
[`Store`](../reference/store.md).
|
||||||
|
|
||||||
Let us use it in our application to implement a central store. This is a pretty
|
Let us use it in our application. This is a pretty large refactoring (for our
|
||||||
large refactoring (for our application), since it involves extracting all task
|
application), since it involves extracting all task related code out of the
|
||||||
related code out of the components. Here is the new content of the `app.js` file:
|
components. Here is the new content of the `app.js` file:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const { Component, mount, xml, useRef, onMounted, useState, reactive, useEnv } = owl;
|
const { Component, Store, mount } = owl;
|
||||||
|
const { xml } = owl.tags;
|
||||||
|
const { whenReady } = owl.utils;
|
||||||
|
const { useRef, useDispatch, useStore } = owl.hooks;
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Store
|
// Store
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
function useStore() {
|
const actions = {
|
||||||
const env = useEnv();
|
addTask({ state }, title) {
|
||||||
return useState(env.store);
|
title = title.trim();
|
||||||
}
|
if (title) {
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// TaskList
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
class TaskList {
|
|
||||||
nextId = 1;
|
|
||||||
tasks = [];
|
|
||||||
|
|
||||||
addTask(text) {
|
|
||||||
text = text.trim();
|
|
||||||
if (text) {
|
|
||||||
const task = {
|
const task = {
|
||||||
id: this.nextId++,
|
id: state.nextId++,
|
||||||
text: text,
|
title: title,
|
||||||
isCompleted: false,
|
isCompleted: false,
|
||||||
};
|
};
|
||||||
this.tasks.push(task);
|
state.tasks.push(task);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
toggleTask({ state }, id) {
|
||||||
toggleTask(task) {
|
const task = state.tasks.find((t) => t.id === id);
|
||||||
task.isCompleted = !task.isCompleted;
|
task.isCompleted = !task.isCompleted;
|
||||||
}
|
},
|
||||||
|
deleteTask({ state }, id) {
|
||||||
deleteTask(task) {
|
const index = state.tasks.findIndex((t) => t.id === id);
|
||||||
const index = this.tasks.findIndex((t) => t.id === task.id);
|
state.tasks.splice(index, 1);
|
||||||
this.tasks.splice(index, 1);
|
},
|
||||||
}
|
};
|
||||||
}
|
const initialState = {
|
||||||
|
nextId: 1,
|
||||||
function createTaskStore() {
|
tasks: [],
|
||||||
return reactive(new TaskList());
|
};
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Task Component
|
// Task Component
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
class Task extends Component {
|
const TASK_TEMPLATE = xml/* xml */ `
|
||||||
static template = xml/* xml */ `
|
|
||||||
<div class="task" t-att-class="props.task.isCompleted ? 'done' : ''">
|
<div class="task" t-att-class="props.task.isCompleted ? 'done' : ''">
|
||||||
<input type="checkbox" t-att-checked="props.task.isCompleted" t-on-click="() => store.toggleTask(props.task)"/>
|
<input type="checkbox" t-att-checked="props.task.isCompleted"
|
||||||
<span><t t-esc="props.task.text"/></span>
|
t-on-click="dispatch('toggleTask', props.task.id)"/>
|
||||||
<span class="delete" t-on-click="() => store.deleteTask(props.task)">🗑</span>
|
<span><t t-esc="props.task.title"/></span>
|
||||||
|
<span class="delete" t-on-click="dispatch('deleteTask', props.task.id)">🗑</span>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
|
class Task extends Component {
|
||||||
|
static template = TASK_TEMPLATE;
|
||||||
static props = ["task"];
|
static props = ["task"];
|
||||||
|
dispatch = useDispatch();
|
||||||
setup() {
|
|
||||||
this.store = useStore();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Root Component
|
// App Component
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
class Root extends Component {
|
const APP_TEMPLATE = xml/* xml */ `
|
||||||
static template = xml/* xml */ `
|
|
||||||
<div class="todo-app">
|
<div class="todo-app">
|
||||||
<input placeholder="Enter a new task" t-on-keyup="addTask" t-ref="add-input"/>
|
<input placeholder="Enter a new task" t-on-keyup="addTask" t-ref="add-input"/>
|
||||||
<div class="task-list">
|
<div class="task-list">
|
||||||
<t t-foreach="store.tasks" t-as="task" t-key="task.id">
|
<t t-foreach="tasks" t-as="task" t-key="task.id">
|
||||||
<Task task="task"/>
|
<Task task="task"/>
|
||||||
</t>
|
</t>
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
|
class App extends Component {
|
||||||
|
static template = APP_TEMPLATE;
|
||||||
static components = { Task };
|
static components = { Task };
|
||||||
|
|
||||||
setup() {
|
inputRef = useRef("add-input");
|
||||||
const inputRef = useRef("add-input");
|
tasks = useStore((state) => state.tasks);
|
||||||
onMounted(() => inputRef.el.focus());
|
dispatch = useDispatch();
|
||||||
this.store = useStore();
|
|
||||||
|
mounted() {
|
||||||
|
this.inputRef.el.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
addTask(ev) {
|
addTask(ev) {
|
||||||
// 13 is keycode for ENTER
|
// 13 is keycode for ENTER
|
||||||
if (ev.keyCode === 13) {
|
if (ev.keyCode === 13) {
|
||||||
this.store.addTask(ev.target.value);
|
this.dispatch("addTask", ev.target.value);
|
||||||
ev.target.value = "";
|
ev.target.value = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Setup
|
// Setup code
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
const env = {
|
function setup() {
|
||||||
store: createTaskStore(),
|
owl.config.mode = "dev";
|
||||||
};
|
const store = new Store({ actions, state: initialState });
|
||||||
mount(Root, document.body, { dev: true, env });
|
App.env.store = store;
|
||||||
|
mount(App, { target: document.body });
|
||||||
|
}
|
||||||
|
|
||||||
|
whenReady(setup);
|
||||||
```
|
```
|
||||||
|
|
||||||
## 11. Saving tasks in local storage
|
## 11-Saving tasks in local storage
|
||||||
|
|
||||||
Now, our TodoApp works great, except if the user closes or refresh the browser!
|
Now, our TodoApp works great, except if the user closes or refresh the browser!
|
||||||
It is really inconvenient to only keep the state of the application in memory.
|
It is really inconvenient to only keep the state of the application in memory.
|
||||||
To fix this, we will save the tasks in the local storage. With our current
|
To fix this, we will save the tasks in the local storage. With our current
|
||||||
codebase, it is a simple change: we need to save tasks to local storage and
|
codebase, it is a simple change: only the setup code needs to be updated.
|
||||||
listen to any change.
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
class TaskList {
|
function makeStore() {
|
||||||
constructor(tasks) {
|
const localState = window.localStorage.getItem("todoapp");
|
||||||
this.tasks = tasks || [];
|
const state = localState ? JSON.parse(localState) : initialState;
|
||||||
const taskIds = this.tasks.map((t) => t.id);
|
const store = new Store({ state, actions });
|
||||||
this.nextId = taskIds.length ? Math.max(...taskIds) + 1 : 1;
|
store.on("update", null, () => {
|
||||||
}
|
localStorage.setItem("todoapp", JSON.stringify(store.state));
|
||||||
// ...
|
});
|
||||||
|
return store;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createTaskStore() {
|
function setup() {
|
||||||
const saveTasks = () => localStorage.setItem("todoapp", JSON.stringify(taskStore.tasks));
|
owl.config.mode = "dev";
|
||||||
const initialTasks = JSON.parse(localStorage.getItem("todoapp") || "[]");
|
const env = { store: makeStore() };
|
||||||
const taskStore = reactive(new TaskList(initialTasks), saveTasks);
|
mount(App, { target: document.body, env });
|
||||||
saveTasks();
|
|
||||||
return taskStore;
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The key point is that the `reactive` function takes a callback that will be called
|
The key point is to use the fact that the store is an
|
||||||
every time an observed value is changed. Note that we need to call the `saveTasks`
|
[`EventBus`](../reference/event_bus.md) which triggers an `update` event
|
||||||
method initially to make sure we observe all current values.
|
whenever it is updated.
|
||||||
|
|
||||||
## 12. Filtering tasks
|
## 12. Filtering tasks
|
||||||
|
|
||||||
We are almost done, we can add/update/delete tasks. The only missing feature is
|
We are almost done, we can add/update/delete tasks. The only missing feature is
|
||||||
the possibility to display the task according to their completed status. We will
|
the possibility to display the task according to their completed status. We will
|
||||||
need to keep track of the state of the filter in `Root`, then filter the visible
|
need to keep track of the state of the filter in `App`, then filter the visible
|
||||||
tasks according to its value.
|
tasks according to its value.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
class Root extends Component {
|
// on top of file, readd useState:
|
||||||
static template = xml /* xml */`
|
const { useRef, useDispatch, useState, useStore } = owl.hooks;
|
||||||
<div class="todo-app">
|
|
||||||
<input placeholder="Enter a new task" t-on-keyup="addTask" t-ref="add-input"/>
|
// in App:
|
||||||
<div class="task-list">
|
filter = useState({value: "all"})
|
||||||
|
|
||||||
|
get displayedTasks() {
|
||||||
|
switch (this.filter.value) {
|
||||||
|
case "active": return this.tasks.filter(t => !t.isCompleted);
|
||||||
|
case "completed": return this.tasks.filter(t => t.isCompleted);
|
||||||
|
case "all": return this.tasks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setFilter(filter) {
|
||||||
|
this.filter.value = filter;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Finally, we need to display the visible filters. We can do that, and at the
|
||||||
|
same time, display the number of tasks in a small panel below the main list:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<div class="todo-app">
|
||||||
|
<input placeholder="Enter a new task" t-on-keyup="addTask" t-ref="add-input"/>
|
||||||
|
<div class="task-list">
|
||||||
<t t-foreach="displayedTasks" t-as="task" t-key="task.id">
|
<t t-foreach="displayedTasks" t-as="task" t-key="task.id">
|
||||||
<Task task="task"/>
|
<Task task="task"/>
|
||||||
</t>
|
</t>
|
||||||
</div>
|
</div>
|
||||||
<div class="task-panel" t-if="store.tasks.length">
|
<div class="task-panel" t-if="tasks.length">
|
||||||
<div class="task-counter">
|
<div class="task-counter">
|
||||||
<t t-esc="displayedTasks.length"/>
|
<t t-esc="displayedTasks.length"/>
|
||||||
<t t-if="displayedTasks.length lt store.tasks.length">
|
<t t-if="displayedTasks.length lt tasks.length">
|
||||||
/ <t t-esc="store.tasks.length"/>
|
/ <t t-esc="tasks.length"/>
|
||||||
</t>
|
</t>
|
||||||
task(s)
|
task(s)
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span t-foreach="['all', 'active', 'completed']"
|
<span t-foreach="['all', 'active', 'completed']"
|
||||||
t-as="f" t-key="f"
|
t-as="f" t-key="f"
|
||||||
t-att-class="{active: filter.value===f}"
|
t-att-class="{active: filter.value===f}"
|
||||||
t-on-click="() => this.setFilter(f)"
|
t-on-click="setFilter(f)"
|
||||||
t-esc="f"/>
|
t-esc="f"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>
|
||||||
|
|
||||||
setup() {
|
|
||||||
...
|
|
||||||
this.filter = useState({ value: "all" });
|
|
||||||
}
|
|
||||||
|
|
||||||
get displayedTasks() {
|
|
||||||
const tasks = this.store.tasks;
|
|
||||||
switch (this.filter.value) {
|
|
||||||
case "active": return tasks.filter(t => !t.isCompleted);
|
|
||||||
case "completed": return tasks.filter(t => t.isCompleted);
|
|
||||||
case "all": return tasks;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setFilter(filter) {
|
|
||||||
this.filter.value = filter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```css
|
```css
|
||||||
@@ -722,8 +753,8 @@ class Root extends Component {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Notice here that we set dynamically the css class of the filter with the object
|
Notice here that we set dynamically the class of the filter with the object
|
||||||
syntax.
|
syntax: each key is a class that we want to set if its value is truthy.
|
||||||
|
|
||||||
## 13. The Final Touch
|
## 13. The Final Touch
|
||||||
|
|
||||||
@@ -738,16 +769,16 @@ the user experience.
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Make the text of a task clickable, to toggle its checkbox:
|
2. Make the title of a task clickable, to toggle its checkbox:
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<input type="checkbox" t-att-checked="props.task.isCompleted"
|
<input type="checkbox" t-att-checked="props.task.isCompleted"
|
||||||
t-att-id="props.task.id"
|
t-att-id="props.task.id"
|
||||||
t-on-click="dispatch('toggleTask', props.task.id)"/>
|
t-on-click="dispatch('toggleTask', props.task.id)"/>
|
||||||
<label t-att-for="props.task.id"><t t-esc="props.task.text"/></label>
|
<label t-att-for="props.task.id"><t t-esc="props.task.title"/></label>
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Strike the text of completed task:
|
3. Strike the title of completed task:
|
||||||
|
|
||||||
```css
|
```css
|
||||||
.task.done label {
|
.task.done label {
|
||||||
@@ -779,145 +810,142 @@ For reference, here is the final code:
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
(function () {
|
(function () {
|
||||||
const { Component, mount, xml, useRef, onMounted, useState, reactive, useEnv } = owl;
|
const { Component, Store, mount } = owl;
|
||||||
|
const { xml } = owl.tags;
|
||||||
|
const { whenReady } = owl.utils;
|
||||||
|
const { useRef, useDispatch, useState, useStore } = owl.hooks;
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Store
|
// Store
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
function useStore() {
|
const actions = {
|
||||||
const env = useEnv();
|
addTask({ state }, title) {
|
||||||
return useState(env.store);
|
title = title.trim();
|
||||||
}
|
if (title) {
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// TaskList
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
class TaskList {
|
|
||||||
constructor(tasks) {
|
|
||||||
this.tasks = tasks || [];
|
|
||||||
const taskIds = this.tasks.map((t) => t.id);
|
|
||||||
this.nextId = taskIds.length ? Math.max(...taskIds) + 1 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
addTask(text) {
|
|
||||||
text = text.trim();
|
|
||||||
if (text) {
|
|
||||||
const task = {
|
const task = {
|
||||||
id: this.nextId++,
|
id: state.nextId++,
|
||||||
text: text,
|
title: title,
|
||||||
isCompleted: false,
|
isCompleted: false,
|
||||||
};
|
};
|
||||||
this.tasks.push(task);
|
state.tasks.push(task);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
toggleTask({ state }, id) {
|
||||||
toggleTask(task) {
|
const task = state.tasks.find((t) => t.id === id);
|
||||||
task.isCompleted = !task.isCompleted;
|
task.isCompleted = !task.isCompleted;
|
||||||
}
|
},
|
||||||
|
deleteTask({ state }, id) {
|
||||||
|
const index = state.tasks.findIndex((t) => t.id === id);
|
||||||
|
state.tasks.splice(index, 1);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
deleteTask(task) {
|
const initialState = {
|
||||||
const index = this.tasks.findIndex((t) => t.id === task.id);
|
nextId: 1,
|
||||||
this.tasks.splice(index, 1);
|
tasks: [],
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
function createTaskStore() {
|
|
||||||
const saveTasks = () => localStorage.setItem("todoapp", JSON.stringify(taskStore.tasks));
|
|
||||||
const initialTasks = JSON.parse(localStorage.getItem("todoapp") || "[]");
|
|
||||||
const taskStore = reactive(new TaskList(initialTasks), saveTasks);
|
|
||||||
saveTasks();
|
|
||||||
return taskStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Task Component
|
// Task Component
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
const TASK_TEMPLATE = xml/* xml */ `
|
||||||
|
<div class="task" t-att-class="props.task.isCompleted ? 'done' : ''">
|
||||||
|
<input type="checkbox" t-att-checked="props.task.isCompleted"
|
||||||
|
t-att-id="props.task.id"
|
||||||
|
t-on-click="dispatch('toggleTask', props.task.id)"/>
|
||||||
|
<label t-att-for="props.task.id"><t t-esc="props.task.title"/></label>
|
||||||
|
<span class="delete" t-on-click="dispatch('deleteTask', props.task.id)">🗑</span>
|
||||||
|
</div>`;
|
||||||
|
|
||||||
class Task extends Component {
|
class Task extends Component {
|
||||||
static template = xml/* xml */ `
|
static template = TASK_TEMPLATE;
|
||||||
<div class="task" t-att-class="props.task.isCompleted ? 'done' : ''">
|
|
||||||
<input type="checkbox"
|
|
||||||
t-att-id="props.task.id"
|
|
||||||
t-att-checked="props.task.isCompleted"
|
|
||||||
t-on-click="() => store.toggleTask(props.task)"/>
|
|
||||||
<label t-att-for="props.task.id"><t t-esc="props.task.text"/></label>
|
|
||||||
<span class="delete" t-on-click="() => store.deleteTask(props.task)">🗑</span>
|
|
||||||
</div>`;
|
|
||||||
|
|
||||||
static props = ["task"];
|
static props = ["task"];
|
||||||
|
dispatch = useDispatch();
|
||||||
setup() {
|
|
||||||
this.store = useStore();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Root Component
|
// App Component
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
class Root extends Component {
|
const APP_TEMPLATE = xml/* xml */ `
|
||||||
static template = xml/* xml */ `
|
<div class="todo-app">
|
||||||
<div class="todo-app">
|
|
||||||
<input placeholder="Enter a new task" t-on-keyup="addTask" t-ref="add-input"/>
|
<input placeholder="Enter a new task" t-on-keyup="addTask" t-ref="add-input"/>
|
||||||
<div class="task-list">
|
<div class="task-list">
|
||||||
<t t-foreach="displayedTasks" t-as="task" t-key="task.id">
|
<Task t-foreach="displayedTasks" t-as="task" t-key="task.id" task="task"/>
|
||||||
<Task task="task"/>
|
|
||||||
</t>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="task-panel" t-if="store.tasks.length">
|
<div class="task-panel" t-if="tasks.length">
|
||||||
<div class="task-counter">
|
<div class="task-counter">
|
||||||
<t t-esc="displayedTasks.length"/>
|
<t t-esc="displayedTasks.length"/>
|
||||||
<t t-if="displayedTasks.length lt store.tasks.length">
|
<t t-if="displayedTasks.length lt tasks.length">
|
||||||
/ <t t-esc="store.tasks.length"/>
|
/ <t t-esc="tasks.length"/>
|
||||||
</t>
|
</t>
|
||||||
task(s)
|
task(s)
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span t-foreach="['all', 'active', 'completed']"
|
<span t-foreach="['all', 'active', 'completed']"
|
||||||
t-as="f" t-key="f"
|
t-as="f" t-key="f"
|
||||||
t-att-class="{active: filter.value===f}"
|
t-att-class="{active: filter.value===f}"
|
||||||
t-on-click="() => this.setFilter(f)"
|
t-on-click="setFilter(f)"
|
||||||
t-esc="f"/>
|
t-esc="f"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
|
class App extends Component {
|
||||||
|
static template = APP_TEMPLATE;
|
||||||
static components = { Task };
|
static components = { Task };
|
||||||
|
|
||||||
setup() {
|
inputRef = useRef("add-input");
|
||||||
const inputRef = useRef("add-input");
|
tasks = useStore((state) => state.tasks);
|
||||||
onMounted(() => inputRef.el.focus());
|
filter = useState({ value: "all" });
|
||||||
this.store = useStore();
|
dispatch = useDispatch();
|
||||||
this.filter = useState({ value: "all" });
|
|
||||||
|
mounted() {
|
||||||
|
this.inputRef.el.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
addTask(ev) {
|
addTask(ev) {
|
||||||
// 13 is keycode for ENTER
|
// 13 is keycode for ENTER
|
||||||
if (ev.keyCode === 13) {
|
if (ev.keyCode === 13) {
|
||||||
this.store.addTask(ev.target.value);
|
this.dispatch("addTask", ev.target.value);
|
||||||
ev.target.value = "";
|
ev.target.value = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get displayedTasks() {
|
get displayedTasks() {
|
||||||
const tasks = this.store.tasks;
|
|
||||||
switch (this.filter.value) {
|
switch (this.filter.value) {
|
||||||
case "active":
|
case "active":
|
||||||
return tasks.filter((t) => !t.isCompleted);
|
return this.tasks.filter((t) => !t.isCompleted);
|
||||||
case "completed":
|
case "completed":
|
||||||
return tasks.filter((t) => t.isCompleted);
|
return this.tasks.filter((t) => t.isCompleted);
|
||||||
case "all":
|
case "all":
|
||||||
return tasks;
|
return this.tasks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setFilter(filter) {
|
setFilter(filter) {
|
||||||
this.filter.value = filter;
|
this.filter.value = filter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Setup
|
// Setup code
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
const env = { store: createTaskStore() };
|
function makeStore() {
|
||||||
mount(Root, document.body, { dev: true, env });
|
const localState = window.localStorage.getItem("todoapp");
|
||||||
|
const state = localState ? JSON.parse(localState) : initialState;
|
||||||
|
const store = new Store({ state, actions });
|
||||||
|
store.on("update", null, () => {
|
||||||
|
localStorage.setItem("todoapp", JSON.stringify(store.state));
|
||||||
|
});
|
||||||
|
return store;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setup() {
|
||||||
|
owl.config.mode = "dev";
|
||||||
|
const env = { store: makeStore() };
|
||||||
|
mount(App, { target: document.body, env });
|
||||||
|
}
|
||||||
|
|
||||||
|
whenReady(setup);
|
||||||
})();
|
})();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ discussed, feel free to open an issue/submit a PR to correct this text.
|
|||||||
- [Tooling/Build Step](#toolingbuild-step)
|
- [Tooling/Build Step](#toolingbuild-step)
|
||||||
- [Templating](#templating)
|
- [Templating](#templating)
|
||||||
- [Asynchronous rendering](#asynchronous-rendering)
|
- [Asynchronous rendering](#asynchronous-rendering)
|
||||||
- [Reactivity](#reactivity)
|
- [Reactiveness](#reactiveness)
|
||||||
|
- [State Management](#state-management)
|
||||||
- [Hooks](#hooks)
|
- [Hooks](#hooks)
|
||||||
|
|
||||||
## Size
|
## Size
|
||||||
@@ -172,7 +173,7 @@ more convoluted. For example, in Vue, you need to use a dynamic import keyword
|
|||||||
that needs to be transpiled at build time in order for the component to be loaded
|
that needs to be transpiled at build time in order for the component to be loaded
|
||||||
asynchronously (see [the documentation](https://vuejs.org/v2/guide/components-dynamic-async.html#Async-Components)).
|
asynchronously (see [the documentation](https://vuejs.org/v2/guide/components-dynamic-async.html#Async-Components)).
|
||||||
|
|
||||||
## Reactivity
|
## Reactiveness
|
||||||
|
|
||||||
React has a simple model: whenever the state changes, it is
|
React has a simple model: whenever the state changes, it is
|
||||||
replaced with a new state (via the `setState` method). Then, the DOM is patched.
|
replaced with a new state (via the `setState` method). Then, the DOM is patched.
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
# 🦉 OWL Documentation 🦉
|
||||||
|
|
||||||
|
## Learning Owl
|
||||||
|
|
||||||
|
Are you new to Owl? This is the place to start!
|
||||||
|
|
||||||
|
- [Tutorial: create a TodoList application](learning/tutorial_todoapp.md)
|
||||||
|
- [Quick Overview](learning/overview.md)
|
||||||
|
- [How to start an Owl project](learning/quick_start.md)
|
||||||
|
- [How to test Components](learning/how_to_test.md)
|
||||||
|
- [How to write Single File Components](learning/how_to_write_sfc.md)
|
||||||
|
|
||||||
|
## Reference
|
||||||
|
|
||||||
|
You will find here a complete reference of every feature, class or object
|
||||||
|
provided by Owl.
|
||||||
|
|
||||||
|
- [Animations](reference/animations.md)
|
||||||
|
- [Browser](reference/browser.md)
|
||||||
|
- [Component](reference/component.md)
|
||||||
|
- [Content](reference/content.md)
|
||||||
|
- [Concurrency Model](reference/concurrency_model.md)
|
||||||
|
- [Configuration](reference/config.md)
|
||||||
|
- [Context](reference/context.md)
|
||||||
|
- [Environment](reference/environment.md)
|
||||||
|
- [Event Bus](reference/event_bus.md)
|
||||||
|
- [Event Handling](reference/event_handling.md)
|
||||||
|
- [Error Handling](reference/error_handling.md)
|
||||||
|
- [Hooks](reference/hooks.md)
|
||||||
|
- [Mounting a component](reference/mounting.md)
|
||||||
|
- [Miscellaneous Components](reference/misc.md)
|
||||||
|
- [Observer](reference/observer.md)
|
||||||
|
- [Props](reference/props.md)
|
||||||
|
- [Props Validation](reference/props_validation.md)
|
||||||
|
- [QWeb Templating Language](reference/qweb_templating_language.md)
|
||||||
|
- [QWeb Engine](reference/qweb_engine.md)
|
||||||
|
- [Slots](reference/slots.md)
|
||||||
|
- [Tags](reference/tags.md)
|
||||||
|
- [Utils](reference/utils.md)
|
||||||
|
|
||||||
|
## Other Topics
|
||||||
|
|
||||||
|
This section provides miscellaneous document that explains some topics
|
||||||
|
which cannot be considered either a tutorial, or reference documentation.
|
||||||
|
|
||||||
|
- [Owl architecture: the Virtual DOM](miscellaneous/vdom.md)
|
||||||
|
- [Owl architecture: the rendering pipeline](miscellaneous/rendering.md)
|
||||||
|
- [Comparison with React/Vue](miscellaneous/comparison.md)
|
||||||
|
- [Why did Odoo built Owl?](miscellaneous/why_owl.md)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Found an issue in the documentation? A broken link? Some outdated information?
|
||||||
|
Please open an issue or submit a PR!
|
||||||
@@ -372,16 +372,6 @@ to be closed:
|
|||||||
useExternalListener(window, "click", this.closeMenu);
|
useExternalListener(window, "click", this.closeMenu);
|
||||||
```
|
```
|
||||||
|
|
||||||
### `useComponent`
|
|
||||||
|
|
||||||
The `useComponent` hook is useful as a building block for some customized hooks,
|
|
||||||
that may need a reference to the component calling them.
|
|
||||||
|
|
||||||
### `useEnv`
|
|
||||||
|
|
||||||
The `useEnv` hook is useful as a building block for some customized hooks,
|
|
||||||
that may need a reference to the env of the component calling them.
|
|
||||||
|
|
||||||
### Making customized hooks
|
### Making customized hooks
|
||||||
|
|
||||||
Hooks are a wonderful way to organize the code of a complex component by feature
|
Hooks are a wonderful way to organize the code of a complex component by feature
|
||||||
|
|||||||
+1
-2
@@ -16,7 +16,7 @@
|
|||||||
"build:bundle": "rollup -c",
|
"build:bundle": "rollup -c",
|
||||||
"build": "npm run build:bundle",
|
"build": "npm run build:bundle",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand --watch --testTimeout=5000000",
|
"test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand --watch",
|
||||||
"test:watch": "jest --watch",
|
"test:watch": "jest --watch",
|
||||||
"playground:serve": "python3 tools/server.py || python tools/server.py",
|
"playground:serve": "python3 tools/server.py || python tools/server.py",
|
||||||
"playground": "npm run build && npm run playground:serve",
|
"playground": "npm run build && npm run playground:serve",
|
||||||
@@ -46,7 +46,6 @@
|
|||||||
"git-rev-sync": "^1.12.0",
|
"git-rev-sync": "^1.12.0",
|
||||||
"github-api": "^3.3.0",
|
"github-api": "^3.3.0",
|
||||||
"jest": "^27.1.0",
|
"jest": "^27.1.0",
|
||||||
"jest-diff": "^27.3.1",
|
|
||||||
"jest-environment-jsdom": "^27.1.0",
|
"jest-environment-jsdom": "^27.1.0",
|
||||||
"live-server": "^1.2.1",
|
"live-server": "^1.2.1",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
|
|||||||
+30
-59
@@ -2,8 +2,7 @@ import { Component } from "../component/component";
|
|||||||
import { ComponentNode } from "../component/component_node";
|
import { ComponentNode } from "../component/component_node";
|
||||||
import { MountOptions } from "../component/fibers";
|
import { MountOptions } from "../component/fibers";
|
||||||
import { Scheduler } from "../component/scheduler";
|
import { Scheduler } from "../component/scheduler";
|
||||||
import { TemplateSet, TemplateSetConfig } from "./template_set";
|
import { TemplateSet } from "./template_set";
|
||||||
import { nodeErrorHandlers } from "../component/error_handling";
|
|
||||||
|
|
||||||
// reimplement dev mode stuff see last change in 0f7a8289a6fb8387c3c1af41c6664b2a8448758f
|
// reimplement dev mode stuff see last change in 0f7a8289a6fb8387c3c1af41c6664b2a8448758f
|
||||||
|
|
||||||
@@ -11,9 +10,12 @@ export interface Env {
|
|||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppConfig extends TemplateSetConfig {
|
export interface AppConfig {
|
||||||
|
dev?: boolean;
|
||||||
env?: Env;
|
env?: Env;
|
||||||
props?: any;
|
translatableAttributes?: string[];
|
||||||
|
translateFn?: (s: string) => string;
|
||||||
|
templates?: string | Document;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEV_MSG = `Owl is running in 'dev' mode.
|
export const DEV_MSG = `Owl is running in 'dev' mode.
|
||||||
@@ -24,69 +26,46 @@ See https://github.com/odoo/owl/blob/master/doc/reference/config.md#mode for mor
|
|||||||
export class App<T extends typeof Component = any> extends TemplateSet {
|
export class App<T extends typeof Component = any> extends TemplateSet {
|
||||||
Root: T;
|
Root: T;
|
||||||
props: any;
|
props: any;
|
||||||
env: Env;
|
env: Env = Object.freeze({});
|
||||||
scheduler = new Scheduler(window.requestAnimationFrame.bind(window));
|
scheduler = new Scheduler(window.requestAnimationFrame.bind(window));
|
||||||
root: ComponentNode | null = null;
|
root: ComponentNode | null = null;
|
||||||
|
|
||||||
constructor(Root: T, config: AppConfig = {}) {
|
constructor(Root: T, props?: any) {
|
||||||
super(config);
|
super();
|
||||||
this.Root = Root;
|
this.Root = Root;
|
||||||
|
this.props = props;
|
||||||
|
}
|
||||||
|
|
||||||
|
configure(config: AppConfig): App<T> {
|
||||||
if (config.dev) {
|
if (config.dev) {
|
||||||
|
this.dev = config.dev;
|
||||||
console.info(DEV_MSG);
|
console.info(DEV_MSG);
|
||||||
}
|
}
|
||||||
const descrs = Object.getOwnPropertyDescriptors(config.env || {});
|
if (config.env) {
|
||||||
this.env = Object.freeze(Object.defineProperties({}, descrs));
|
this.env = Object.freeze(Object.assign({}, config.env));
|
||||||
this.props = config.props || {};
|
}
|
||||||
|
if (config.translateFn) {
|
||||||
|
this.translateFn = config.translateFn;
|
||||||
|
}
|
||||||
|
if (config.translatableAttributes) {
|
||||||
|
this.translatableAttributes = config.translatableAttributes;
|
||||||
|
}
|
||||||
|
if (config.templates) {
|
||||||
|
this.addTemplates(config.templates);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
mount(target: HTMLElement, options?: MountOptions): Promise<InstanceType<T>> {
|
mount(target: HTMLElement, options?: MountOptions): Promise<InstanceType<T>> {
|
||||||
this.checkTarget(target);
|
|
||||||
const node = this.makeNode(this.Root, this.props);
|
|
||||||
const prom = this.mountNode(node, target, options);
|
|
||||||
this.root = node;
|
|
||||||
return prom;
|
|
||||||
}
|
|
||||||
|
|
||||||
checkTarget(target: HTMLElement) {
|
|
||||||
if (!(target instanceof HTMLElement)) {
|
if (!(target instanceof HTMLElement)) {
|
||||||
throw new Error("Cannot mount component: the target is not a valid DOM element");
|
throw new Error("Cannot mount component: the target is not a valid DOM element");
|
||||||
}
|
}
|
||||||
if (!document.body.contains(target)) {
|
if (!document.body.contains(target)) {
|
||||||
throw new Error("Cannot mount a component on a detached dom node");
|
throw new Error("Cannot mount a component on a detached dom node");
|
||||||
}
|
}
|
||||||
}
|
const node = new ComponentNode(this.Root, this.props, this);
|
||||||
|
this.root = node;
|
||||||
makeNode(Component: T, props: any): ComponentNode {
|
return node.mountComponent(target, options);
|
||||||
return new ComponentNode(Component, props, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
mountNode(node: ComponentNode, target: HTMLElement, options?: MountOptions) {
|
|
||||||
const promise: any = new Promise((resolve, reject) => {
|
|
||||||
let isResolved = false;
|
|
||||||
// manually set a onMounted callback.
|
|
||||||
// that way, we are independant from the current node.
|
|
||||||
node.mounted.push(() => {
|
|
||||||
resolve(node.component);
|
|
||||||
isResolved = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Manually add the last resort error handler on the node
|
|
||||||
let handlers = nodeErrorHandlers.get(node);
|
|
||||||
if (!handlers) {
|
|
||||||
handlers = [];
|
|
||||||
nodeErrorHandlers.set(node, handlers);
|
|
||||||
}
|
|
||||||
handlers.unshift((e) => {
|
|
||||||
if (isResolved) {
|
|
||||||
console.error(e);
|
|
||||||
} else {
|
|
||||||
reject(e);
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
node.mountComponent(target, options);
|
|
||||||
return promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
@@ -95,11 +74,3 @@ export class App<T extends typeof Component = any> extends TemplateSet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function mount<T extends typeof Component>(
|
|
||||||
C: T,
|
|
||||||
target: HTMLElement,
|
|
||||||
config: AppConfig & MountOptions = {}
|
|
||||||
): Promise<InstanceType<T>> {
|
|
||||||
return new App(C, config).mount(target, config);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { BDom, multi, text, toggler } from "../blockdom";
|
|||||||
import { validateProps } from "../component/props_validation";
|
import { validateProps } from "../component/props_validation";
|
||||||
import { Markup } from "../utils";
|
import { Markup } from "../utils";
|
||||||
import { html } from "../blockdom/index";
|
import { html } from "../blockdom/index";
|
||||||
import { VPortal } from "../portal";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file contains utility functions that will be injected in each template,
|
* This file contains utility functions that will be injected in each template,
|
||||||
@@ -13,17 +12,6 @@ function withDefault(value: any, defaultValue: any): any {
|
|||||||
return value === undefined || value === null || value === false ? defaultValue : value;
|
return value === undefined || value === null || value === false ? defaultValue : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function callPortal(
|
|
||||||
ctx: any,
|
|
||||||
parent: any,
|
|
||||||
key: string,
|
|
||||||
target: string,
|
|
||||||
content: (ctx: any, node: any, key: string) => BDom
|
|
||||||
): BDom {
|
|
||||||
const portal = new VPortal(target, content(ctx, parent, key), ctx.__owl__) as any;
|
|
||||||
return portal;
|
|
||||||
}
|
|
||||||
|
|
||||||
function callSlot(
|
function callSlot(
|
||||||
ctx: any,
|
ctx: any,
|
||||||
parent: any,
|
parent: any,
|
||||||
@@ -113,25 +101,6 @@ function shallowEqual(l1: any[], l2: any[]): boolean {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
class LazyValue {
|
|
||||||
fn: any;
|
|
||||||
ctx: any;
|
|
||||||
node: any;
|
|
||||||
constructor(fn: any, ctx: any, node: any) {
|
|
||||||
this.fn = fn;
|
|
||||||
this.ctx = capture(ctx);
|
|
||||||
this.node = node;
|
|
||||||
}
|
|
||||||
|
|
||||||
evaluate(): any {
|
|
||||||
return this.fn(this.ctx, this.node);
|
|
||||||
}
|
|
||||||
|
|
||||||
toString() {
|
|
||||||
return this.evaluate().toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Safely outputs `value` as a block depending on the nature of `value`
|
* Safely outputs `value` as a block depending on the nature of `value`
|
||||||
*/
|
*/
|
||||||
@@ -144,9 +113,6 @@ export function safeOutput(value: any): ReturnType<typeof toggler> {
|
|||||||
if (value instanceof Markup) {
|
if (value instanceof Markup) {
|
||||||
safeKey = `string_safe`;
|
safeKey = `string_safe`;
|
||||||
block = html(value as string);
|
block = html(value as string);
|
||||||
} else if (value instanceof LazyValue) {
|
|
||||||
safeKey = `lazy_value`;
|
|
||||||
block = value.evaluate();
|
|
||||||
} else if (typeof value === "string") {
|
} else if (typeof value === "string") {
|
||||||
safeKey = "string_unsafe";
|
safeKey = "string_unsafe";
|
||||||
block = text(value);
|
block = text(value);
|
||||||
@@ -158,56 +124,17 @@ export function safeOutput(value: any): ReturnType<typeof toggler> {
|
|||||||
return toggler(safeKey, block);
|
return toggler(safeKey, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
let boundFunctions = new WeakMap();
|
|
||||||
|
|
||||||
function bind(ctx: any, fn: Function): Function {
|
|
||||||
let component = ctx.__owl__.component;
|
|
||||||
let boundFnMap = boundFunctions.get(component);
|
|
||||||
if (!boundFnMap) {
|
|
||||||
boundFnMap = new WeakMap();
|
|
||||||
boundFunctions.set(component, boundFnMap);
|
|
||||||
}
|
|
||||||
let boundFn = boundFnMap.get(fn);
|
|
||||||
if (!boundFn) {
|
|
||||||
boundFn = fn.bind(component);
|
|
||||||
boundFnMap.set(fn, boundFn);
|
|
||||||
}
|
|
||||||
return boundFn;
|
|
||||||
}
|
|
||||||
|
|
||||||
type RefMap = { [key: string]: HTMLElement | null };
|
|
||||||
type RefSetter = (el: HTMLElement | null) => void;
|
|
||||||
|
|
||||||
function multiRefSetter(refs: RefMap, name: string): RefSetter {
|
|
||||||
let count = 0;
|
|
||||||
return (el) => {
|
|
||||||
if (el) {
|
|
||||||
count++;
|
|
||||||
if (count > 1) {
|
|
||||||
throw new Error("Cannot have 2 elements with same ref name at the same time");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (count === 0 || el) {
|
|
||||||
refs[name] = el;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export const UTILS = {
|
export const UTILS = {
|
||||||
withDefault,
|
withDefault,
|
||||||
zero: Symbol("zero"),
|
zero: Symbol("zero"),
|
||||||
isBoundary,
|
isBoundary,
|
||||||
callSlot,
|
callSlot,
|
||||||
callPortal,
|
|
||||||
capture,
|
capture,
|
||||||
withKey,
|
withKey,
|
||||||
prepareList,
|
prepareList,
|
||||||
setContextValue,
|
setContextValue,
|
||||||
multiRefSetter,
|
|
||||||
shallowEqual,
|
shallowEqual,
|
||||||
toNumber,
|
toNumber,
|
||||||
validateProps,
|
validateProps,
|
||||||
LazyValue,
|
|
||||||
safeOutput,
|
safeOutput,
|
||||||
bind,
|
|
||||||
};
|
};
|
||||||
|
|||||||
+19
-46
@@ -1,9 +1,9 @@
|
|||||||
import { createBlock, html, list, multi, text, toggler, comment } from "../blockdom";
|
import { createBlock, html, list, multi, text, toggler } from "../blockdom";
|
||||||
import { compile, Template } from "../compiler";
|
import { compile, Template } from "../compiler";
|
||||||
import { component } from "../component/component_node";
|
import { component } from "../component/component_node";
|
||||||
import { UTILS } from "./template_helpers";
|
import { UTILS } from "./template_helpers";
|
||||||
|
|
||||||
const bdom = { text, createBlock, list, multi, html, toggler, component, comment };
|
const bdom = { text, createBlock, list, multi, html, toggler, component };
|
||||||
|
|
||||||
export const globalTemplates: { [key: string]: string | Node } = {};
|
export const globalTemplates: { [key: string]: string | Node } = {};
|
||||||
|
|
||||||
@@ -37,34 +37,22 @@ function parseXML(xml: string): Document {
|
|||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TemplateSetConfig {
|
|
||||||
dev?: boolean;
|
|
||||||
translatableAttributes?: string[];
|
|
||||||
translateFn?: (s: string) => string;
|
|
||||||
templates?: string | Document;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class TemplateSet {
|
export class TemplateSet {
|
||||||
dev: boolean;
|
|
||||||
rawTemplates: typeof globalTemplates = Object.create(globalTemplates);
|
rawTemplates: typeof globalTemplates = Object.create(globalTemplates);
|
||||||
templates: { [name: string]: Template } = {};
|
templates: { [name: string]: Template } = {};
|
||||||
translateFn?: (s: string) => string;
|
translateFn?: (s: string) => string;
|
||||||
translatableAttributes?: string[];
|
translatableAttributes?: string[];
|
||||||
utils: typeof UTILS = Object.assign({}, UTILS, {
|
utils: typeof UTILS;
|
||||||
call: (owner: any, subTemplate: string, ctx: any, parent: any, key: any) => {
|
dev?: boolean;
|
||||||
const template = this.getTemplate(subTemplate);
|
|
||||||
return toggler(subTemplate, template.call(owner, ctx, parent, key));
|
|
||||||
},
|
|
||||||
getTemplate: (name: string) => this.getTemplate(name),
|
|
||||||
});
|
|
||||||
|
|
||||||
constructor(config: TemplateSetConfig = {}) {
|
constructor() {
|
||||||
this.dev = config.dev || false;
|
const call = (subTemplate: string, ctx: any, parent: any) => {
|
||||||
this.translateFn = config.translateFn;
|
const template = this.getTemplate(subTemplate);
|
||||||
this.translatableAttributes = config.translatableAttributes;
|
return toggler(subTemplate, template(ctx, parent));
|
||||||
if (config.templates) {
|
};
|
||||||
this.addTemplates(config.templates);
|
|
||||||
}
|
const getTemplate = (name: string) => this.getTemplate(name);
|
||||||
|
this.utils = Object.assign({}, UTILS, { getTemplate, call });
|
||||||
}
|
}
|
||||||
|
|
||||||
addTemplate(name: string, template: string | Node, options: { allowDuplicate?: boolean } = {}) {
|
addTemplate(name: string, template: string | Node, options: { allowDuplicate?: boolean } = {}) {
|
||||||
@@ -93,7 +81,13 @@ export class TemplateSet {
|
|||||||
if (rawTemplate === undefined) {
|
if (rawTemplate === undefined) {
|
||||||
throw new Error(`Missing template: "${name}"`);
|
throw new Error(`Missing template: "${name}"`);
|
||||||
}
|
}
|
||||||
const templateFn = this._compileTemplate(name, rawTemplate);
|
const templateFn = compile(rawTemplate, {
|
||||||
|
name,
|
||||||
|
dev: this.dev,
|
||||||
|
translateFn: this.translateFn,
|
||||||
|
translatableAttributes: this.translatableAttributes,
|
||||||
|
});
|
||||||
|
|
||||||
// first add a function to lazily get the template, in case there is a
|
// first add a function to lazily get the template, in case there is a
|
||||||
// recursive call to the template name
|
// recursive call to the template name
|
||||||
this.templates[name] = (context, parent) => this.templates[name](context, parent);
|
this.templates[name] = (context, parent) => this.templates[name](context, parent);
|
||||||
@@ -102,25 +96,4 @@ export class TemplateSet {
|
|||||||
}
|
}
|
||||||
return this.templates[name];
|
return this.templates[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
_compileTemplate(name: string, template: string | Node) {
|
|
||||||
return compile(template, {
|
|
||||||
name,
|
|
||||||
dev: this.dev,
|
|
||||||
translateFn: this.translateFn,
|
|
||||||
translatableAttributes: this.translatableAttributes,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// xml tag helper
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
export function xml(...args: Parameters<typeof String.raw>) {
|
|
||||||
const name = `__template__${xml.nextId++}`;
|
|
||||||
const value = String.raw(...args);
|
|
||||||
globalTemplates[name] = value;
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
xml.nextId = 1;
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { Setter } from "./block_compiler";
|
import type { Setter } from "./block_compiler";
|
||||||
|
|
||||||
const { setAttribute: elemSetAttribute, removeAttribute } = Element.prototype;
|
const { setAttribute, removeAttribute } = Element.prototype;
|
||||||
const tokenList = DOMTokenList.prototype;
|
const tokenList = DOMTokenList.prototype;
|
||||||
const tokenListAdd = tokenList.add;
|
const tokenListAdd = tokenList.add;
|
||||||
const tokenListRemove = tokenList.remove;
|
const tokenListRemove = tokenList.remove;
|
||||||
@@ -14,23 +14,11 @@ const wordRegexp = /\s+/;
|
|||||||
* file.
|
* file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function setAttribute(this: HTMLElement, key: string, value: any) {
|
|
||||||
switch (value) {
|
|
||||||
case false:
|
|
||||||
case undefined:
|
|
||||||
removeAttribute.call(this, key);
|
|
||||||
break;
|
|
||||||
case true:
|
|
||||||
elemSetAttribute.call(this, key, "");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
elemSetAttribute.call(this, key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createAttrUpdater(attr: string): Setter<HTMLElement> {
|
export function createAttrUpdater(attr: string): Setter<HTMLElement> {
|
||||||
return function (this: HTMLElement, value: any) {
|
return function (this: HTMLElement, value: any) {
|
||||||
setAttribute.call(this, attr, value);
|
if (value !== false) {
|
||||||
|
setAttribute.call(this, attr, value === true ? "" : value);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ const cache: { [key: string]: BlockType } = {};
|
|||||||
* @param str
|
* @param str
|
||||||
* @returns a new block type, that can build concrete blocks
|
* @returns a new block type, that can build concrete blocks
|
||||||
*/
|
*/
|
||||||
export function createBlock(str: string, deepRemove: boolean = false): BlockType {
|
export function createBlock(str: string): BlockType {
|
||||||
if (str in cache) {
|
if (str in cache) {
|
||||||
return cache[str];
|
return cache[str];
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ export function createBlock(str: string, deepRemove: boolean = false): BlockType
|
|||||||
|
|
||||||
// step 3: build the final block class
|
// step 3: build the final block class
|
||||||
const template = tree.el as HTMLElement;
|
const template = tree.el as HTMLElement;
|
||||||
const Block = buildBlock(template, context, deepRemove);
|
const Block = buildBlock(template, context);
|
||||||
cache[str] = Block;
|
cache[str] = Block;
|
||||||
return Block;
|
return Block;
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ interface IntermediateTree {
|
|||||||
nextSibling: IntermediateTree | null;
|
nextSibling: IntermediateTree | null;
|
||||||
el: Node;
|
el: Node;
|
||||||
info: DynamicInfo[];
|
info: DynamicInfo[];
|
||||||
isRef?: boolean;
|
forceRef?: boolean;
|
||||||
refIdx?: number;
|
refIdx?: number;
|
||||||
refN: number;
|
refN: number;
|
||||||
currentNS: string | null;
|
currentNS: string | null;
|
||||||
@@ -127,7 +127,8 @@ function buildTree(
|
|||||||
switch (node.nodeType) {
|
switch (node.nodeType) {
|
||||||
case Node.ELEMENT_NODE: {
|
case Node.ELEMENT_NODE: {
|
||||||
// HTMLElement
|
// HTMLElement
|
||||||
let currentNS = domParentTree && domParentTree.currentNS;
|
let isActive = false;
|
||||||
|
let currentNS = parent && parent.currentNS;
|
||||||
const tagName = (node as Element).tagName;
|
const tagName = (node as Element).tagName;
|
||||||
let el: Node | undefined = undefined;
|
let el: Node | undefined = undefined;
|
||||||
const info: DynamicInfo[] = [];
|
const info: DynamicInfo[] = [];
|
||||||
@@ -135,14 +136,14 @@ function buildTree(
|
|||||||
const index = parseInt(tagName.slice(11), 10);
|
const index = parseInt(tagName.slice(11), 10);
|
||||||
info.push({ type: "text", idx: index });
|
info.push({ type: "text", idx: index });
|
||||||
el = document.createTextNode("");
|
el = document.createTextNode("");
|
||||||
|
isActive = true;
|
||||||
}
|
}
|
||||||
if (tagName.startsWith("block-child-")) {
|
if (tagName.startsWith("block-child-")) {
|
||||||
if (!domParentTree!.isRef) {
|
domParentTree!.forceRef = true;
|
||||||
addRef(domParentTree!);
|
|
||||||
}
|
|
||||||
const index = parseInt(tagName.slice(12), 10);
|
const index = parseInt(tagName.slice(12), 10);
|
||||||
info.push({ type: "child", idx: index });
|
info.push({ type: "child", idx: index });
|
||||||
el = document.createTextNode("");
|
el = document.createTextNode("");
|
||||||
|
isActive = true;
|
||||||
}
|
}
|
||||||
const attrs = (node as Element).attributes;
|
const attrs = (node as Element).attributes;
|
||||||
const ns = attrs.getNamedItem("block-ns");
|
const ns = attrs.getNamedItem("block-ns");
|
||||||
@@ -160,6 +161,7 @@ function buildTree(
|
|||||||
const attrName = attrs[i].name;
|
const attrName = attrs[i].name;
|
||||||
const attrValue = attrs[i].value;
|
const attrValue = attrs[i].value;
|
||||||
if (attrName.startsWith("block-handler-")) {
|
if (attrName.startsWith("block-handler-")) {
|
||||||
|
isActive = true;
|
||||||
const idx = parseInt(attrName.slice(14), 10);
|
const idx = parseInt(attrName.slice(14), 10);
|
||||||
info.push({
|
info.push({
|
||||||
type: "handler",
|
type: "handler",
|
||||||
@@ -167,6 +169,7 @@ function buildTree(
|
|||||||
event: attrValue,
|
event: attrValue,
|
||||||
});
|
});
|
||||||
} else if (attrName.startsWith("block-attribute-")) {
|
} else if (attrName.startsWith("block-attribute-")) {
|
||||||
|
isActive = true;
|
||||||
const idx = parseInt(attrName.slice(16), 10);
|
const idx = parseInt(attrName.slice(16), 10);
|
||||||
info.push({
|
info.push({
|
||||||
type: "attribute",
|
type: "attribute",
|
||||||
@@ -175,11 +178,13 @@ function buildTree(
|
|||||||
tag: tagName,
|
tag: tagName,
|
||||||
});
|
});
|
||||||
} else if (attrName === "block-attributes") {
|
} else if (attrName === "block-attributes") {
|
||||||
|
isActive = true;
|
||||||
info.push({
|
info.push({
|
||||||
type: "attributes",
|
type: "attributes",
|
||||||
idx: parseInt(attrValue, 10),
|
idx: parseInt(attrValue, 10),
|
||||||
});
|
});
|
||||||
} else if (attrName === "block-ref") {
|
} else if (attrName === "block-ref") {
|
||||||
|
isActive = true;
|
||||||
info.push({
|
info.push({
|
||||||
type: "ref",
|
type: "ref",
|
||||||
idx: parseInt(attrValue, 10),
|
idx: parseInt(attrValue, 10),
|
||||||
@@ -196,7 +201,7 @@ function buildTree(
|
|||||||
nextSibling: null,
|
nextSibling: null,
|
||||||
el,
|
el,
|
||||||
info,
|
info,
|
||||||
refN: 0,
|
refN: isActive ? 1 : 0,
|
||||||
currentNS,
|
currentNS,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -210,6 +215,8 @@ function buildTree(
|
|||||||
const tagName = (childNode as Element).tagName;
|
const tagName = (childNode as Element).tagName;
|
||||||
const index = parseInt(tagName.slice(12), 10);
|
const index = parseInt(tagName.slice(12), 10);
|
||||||
info.push({ idx: index, type: "child", isOnlyChild: true });
|
info.push({ idx: index, type: "child", isOnlyChild: true });
|
||||||
|
isActive = true;
|
||||||
|
tree.refN = 1;
|
||||||
} else {
|
} else {
|
||||||
tree.firstChild = buildTree(node.firstChild, tree, tree);
|
tree.firstChild = buildTree(node.firstChild, tree, tree);
|
||||||
el.appendChild(tree.firstChild.el);
|
el.appendChild(tree.firstChild.el);
|
||||||
@@ -222,8 +229,11 @@ function buildTree(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tree.info.length) {
|
if (isActive) {
|
||||||
addRef(tree);
|
let cur: IntermediateTree | null = tree;
|
||||||
|
while ((cur = cur.parent)) {
|
||||||
|
cur.refN++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return tree;
|
return tree;
|
||||||
}
|
}
|
||||||
@@ -248,13 +258,6 @@ function buildTree(
|
|||||||
throw new Error("boom");
|
throw new Error("boom");
|
||||||
}
|
}
|
||||||
|
|
||||||
function addRef(tree: IntermediateTree) {
|
|
||||||
tree.isRef = true;
|
|
||||||
do {
|
|
||||||
tree.refN++;
|
|
||||||
} while ((tree = tree.parent as any));
|
|
||||||
}
|
|
||||||
|
|
||||||
function parentTree(tree: IntermediateTree): IntermediateTree | null {
|
function parentTree(tree: IntermediateTree): IntermediateTree | null {
|
||||||
let parent = tree.parent;
|
let parent = tree.parent;
|
||||||
while (parent && parent.nextSibling === tree) {
|
while (parent && parent.nextSibling === tree) {
|
||||||
@@ -301,15 +304,21 @@ interface BlockCtx {
|
|||||||
cbRefs: number[];
|
cbRefs: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildContext(tree: IntermediateTree, ctx?: BlockCtx, fromIdx?: number): BlockCtx {
|
function buildContext(
|
||||||
|
tree: IntermediateTree,
|
||||||
|
ctx?: BlockCtx,
|
||||||
|
fromIdx?: number,
|
||||||
|
toIdx?: number
|
||||||
|
): BlockCtx {
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
const children = new Array(tree.info.filter((v) => v.type === "child").length);
|
const children = new Array(tree.info.filter((v) => v.type === "child").length);
|
||||||
ctx = { collectors: [], locations: [], children, cbRefs: [], refN: tree.refN };
|
ctx = { collectors: [], locations: [], children, cbRefs: [], refN: tree.refN };
|
||||||
fromIdx = 0;
|
fromIdx = 0;
|
||||||
|
toIdx = tree.refN - 1;
|
||||||
}
|
}
|
||||||
if (tree.refN) {
|
if (tree.refN) {
|
||||||
const initialIdx = fromIdx!;
|
const initialIdx = fromIdx!;
|
||||||
const isRef = tree.isRef;
|
const isRef = tree.forceRef || tree.info.length > 0;
|
||||||
const firstChild = tree.firstChild ? tree.firstChild.refN : 0;
|
const firstChild = tree.firstChild ? tree.firstChild.refN : 0;
|
||||||
const nextSibling = tree.nextSibling ? tree.nextSibling.refN : 0;
|
const nextSibling = tree.nextSibling ? tree.nextSibling.refN : 0;
|
||||||
|
|
||||||
@@ -327,13 +336,13 @@ function buildContext(tree: IntermediateTree, ctx?: BlockCtx, fromIdx?: number):
|
|||||||
if (nextSibling) {
|
if (nextSibling) {
|
||||||
const idx = fromIdx! + firstChild;
|
const idx = fromIdx! + firstChild;
|
||||||
ctx.collectors.push({ idx, prevIdx: initialIdx, getVal: nodeGetNextSibling });
|
ctx.collectors.push({ idx, prevIdx: initialIdx, getVal: nodeGetNextSibling });
|
||||||
buildContext(tree.nextSibling!, ctx, idx);
|
buildContext(tree.nextSibling!, ctx, idx, toIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// left
|
// left
|
||||||
if (firstChild) {
|
if (firstChild) {
|
||||||
ctx.collectors.push({ idx: fromIdx!, prevIdx: initialIdx, getVal: nodeGetFirstChild });
|
ctx.collectors.push({ idx: fromIdx!, prevIdx: initialIdx, getVal: nodeGetFirstChild });
|
||||||
buildContext(tree.firstChild!, ctx, fromIdx!);
|
buildContext(tree.firstChild!, ctx, fromIdx!, toIdx! - nextSibling);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,7 +431,7 @@ function updateCtx(ctx: BlockCtx, tree: IntermediateTree) {
|
|||||||
// building the concrete block class
|
// building the concrete block class
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
function buildBlock(template: HTMLElement, ctx: BlockCtx, deepRemove: boolean): BlockType {
|
function buildBlock(template: HTMLElement, ctx: BlockCtx): BlockType {
|
||||||
let B = createBlockClass(template, ctx);
|
let B = createBlockClass(template, ctx);
|
||||||
|
|
||||||
if (ctx.cbRefs.length) {
|
if (ctx.cbRefs.length) {
|
||||||
@@ -447,14 +456,6 @@ function buildBlock(template: HTMLElement, ctx: BlockCtx, deepRemove: boolean):
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
B.prototype.beforeRemove = VMulti.prototype.beforeRemove;
|
B.prototype.beforeRemove = VMulti.prototype.beforeRemove;
|
||||||
if (deepRemove) {
|
|
||||||
const blockRemove = B.prototype.remove;
|
|
||||||
const vMultiRemove = VMulti.prototype.remove;
|
|
||||||
B.prototype.remove = function () {
|
|
||||||
blockRemove.call(this);
|
|
||||||
vMultiRemove.call(this);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return (data?: any[], children: (VNode | undefined)[] = []) => new B(data, children);
|
return (data?: any[], children: (VNode | undefined)[] = []) => new B(data, children);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,7 +499,6 @@ function createBlockClass(template: HTMLElement, ctx: BlockCtx): BlockClass {
|
|||||||
beforeRemove() {}
|
beforeRemove() {}
|
||||||
|
|
||||||
remove() {
|
remove() {
|
||||||
console.log('ddd')
|
|
||||||
elementRemove.call(this.el);
|
elementRemove.call(this.el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ export { toggler } from "./toggler";
|
|||||||
export { createBlock } from "./block_compiler";
|
export { createBlock } from "./block_compiler";
|
||||||
export { list } from "./list";
|
export { list } from "./list";
|
||||||
export { multi } from "./multi";
|
export { multi } from "./multi";
|
||||||
export { text, comment } from "./text";
|
export { text } from "./text";
|
||||||
export { html } from "./html";
|
export { html } from "./html";
|
||||||
|
|
||||||
export interface VNode<T = any> {
|
export interface VNode<T = any> {
|
||||||
|
|||||||
@@ -17,11 +17,9 @@ class VList {
|
|||||||
anchor: Node | undefined;
|
anchor: Node | undefined;
|
||||||
parentEl?: HTMLElement | undefined;
|
parentEl?: HTMLElement | undefined;
|
||||||
isOnlyChild?: boolean | undefined;
|
isOnlyChild?: boolean | undefined;
|
||||||
deepRemove: boolean;
|
|
||||||
|
|
||||||
constructor(children: VNode[], deepRemove: boolean) {
|
constructor(children: VNode[]) {
|
||||||
this.children = children;
|
this.children = children;
|
||||||
this.deepRemove = deepRemove;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mount(parent: HTMLElement, afterNode: Node | null) {
|
mount(parent: HTMLElement, afterNode: Node | null) {
|
||||||
@@ -77,7 +75,7 @@ class VList {
|
|||||||
const parent = this.parentEl!;
|
const parent = this.parentEl!;
|
||||||
|
|
||||||
// fast path: no new child => only remove
|
// fast path: no new child => only remove
|
||||||
if (ch2.length === 0 && isOnlyChild && !this.deepRemove) {
|
if (ch2.length === 0 && isOnlyChild) {
|
||||||
if (withBeforeRemove) {
|
if (withBeforeRemove) {
|
||||||
for (let i = 0, l = ch1.length; i < l; i++) {
|
for (let i = 0, l = ch1.length; i < l; i++) {
|
||||||
beforeRemove.call(ch1[i]);
|
beforeRemove.call(ch1[i]);
|
||||||
@@ -100,6 +98,7 @@ class VList {
|
|||||||
let endVn2 = ch2[endIdx2];
|
let endVn2 = ch2[endIdx2];
|
||||||
|
|
||||||
let mapping: any = undefined;
|
let mapping: any = undefined;
|
||||||
|
// let noFullRemove = this.hasNoComponent;
|
||||||
|
|
||||||
while (startIdx1 <= endIdx1 && startIdx2 <= endIdx2) {
|
while (startIdx1 <= endIdx1 && startIdx2 <= endIdx2) {
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
@@ -203,7 +202,7 @@ class VList {
|
|||||||
|
|
||||||
remove() {
|
remove() {
|
||||||
const { parentEl, anchor } = this;
|
const { parentEl, anchor } = this;
|
||||||
if (this.isOnlyChild && !this.deepRemove) {
|
if (this.isOnlyChild) {
|
||||||
nodeSetTextContent.call(parentEl, "");
|
nodeSetTextContent.call(parentEl, "");
|
||||||
} else {
|
} else {
|
||||||
const children = this.children;
|
const children = this.children;
|
||||||
@@ -228,8 +227,8 @@ class VList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function list(children: VNode[], deepRemove = false): VNode<VList> {
|
export function list(children: VNode[]): VNode<VList> {
|
||||||
return new VList(children, deepRemove);
|
return new VList(children);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createMapping(ch1: any[], startIdx1: number, endIdx2: number): { [key: string]: any } {
|
function createMapping(ch1: any[], startIdx1: number, endIdx2: number): { [key: string]: any } {
|
||||||
|
|||||||
@@ -15,11 +15,9 @@ export class VMulti {
|
|||||||
anchors?: Node[] | undefined;
|
anchors?: Node[] | undefined;
|
||||||
parentEl?: HTMLElement | undefined;
|
parentEl?: HTMLElement | undefined;
|
||||||
isOnlyChild?: boolean | undefined;
|
isOnlyChild?: boolean | undefined;
|
||||||
deepRemove: boolean;
|
|
||||||
|
|
||||||
constructor(children: (VNode | undefined)[], deepRemove: boolean) {
|
constructor(children: (VNode | undefined)[]) {
|
||||||
this.children = children;
|
this.children = children;
|
||||||
this.deepRemove = deepRemove;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mount(parent: HTMLElement, afterNode: Node | null) {
|
mount(parent: HTMLElement, afterNode: Node | null) {
|
||||||
@@ -105,7 +103,7 @@ export class VMulti {
|
|||||||
|
|
||||||
remove() {
|
remove() {
|
||||||
const parentEl = this.parentEl;
|
const parentEl = this.parentEl;
|
||||||
if (this.isOnlyChild && !this.deepRemove) {
|
if (this.isOnlyChild) {
|
||||||
nodeSetTextContent.call(parentEl, "");
|
nodeSetTextContent.call(parentEl, "");
|
||||||
} else {
|
} else {
|
||||||
const children = this.children;
|
const children = this.children;
|
||||||
@@ -131,6 +129,6 @@ export class VMulti {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function multi(children: (VNode | undefined)[], deepRemove = false): VNode<VMulti> {
|
export function multi(children: (VNode | undefined)[]): VNode<VMulti> {
|
||||||
return new VMulti(children, deepRemove);
|
return new VMulti(children);
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-29
@@ -8,17 +8,18 @@ const nodeInsertBefore = nodeProto.insertBefore;
|
|||||||
const characterDataSetData = getDescriptor(characterDataProto, "data").set!;
|
const characterDataSetData = getDescriptor(characterDataProto, "data").set!;
|
||||||
const nodeRemoveChild = nodeProto.removeChild;
|
const nodeRemoveChild = nodeProto.removeChild;
|
||||||
|
|
||||||
abstract class VSimpleNode {
|
class VText {
|
||||||
text: string;
|
text: string;
|
||||||
parentEl?: HTMLElement | undefined;
|
parentEl?: HTMLElement | undefined;
|
||||||
el?: any;
|
el?: Text;
|
||||||
|
|
||||||
constructor(text: string) {
|
constructor(text: string) {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
mountNode(node: Node, parent: HTMLElement, afterNode: Node | null) {
|
mount(parent: HTMLElement, afterNode: Node | null) {
|
||||||
this.parentEl = parent;
|
this.parentEl = parent;
|
||||||
|
const node = document.createTextNode(toText(this.text));
|
||||||
nodeInsertBefore.call(parent, node, afterNode);
|
nodeInsertBefore.call(parent, node, afterNode);
|
||||||
this.el = node;
|
this.el = node;
|
||||||
}
|
}
|
||||||
@@ -28,6 +29,14 @@ abstract class VSimpleNode {
|
|||||||
nodeInsertBefore.call(this.parentEl, this.el!, target);
|
nodeInsertBefore.call(this.parentEl, this.el!, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
patch(other: VText) {
|
||||||
|
const text2 = other.text;
|
||||||
|
if (this.text !== text2) {
|
||||||
|
characterDataSetData.call(this.el!, toText(text2));
|
||||||
|
this.text = text2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
beforeRemove() {}
|
beforeRemove() {}
|
||||||
|
|
||||||
remove() {
|
remove() {
|
||||||
@@ -43,36 +52,10 @@ abstract class VSimpleNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class VText extends VSimpleNode {
|
|
||||||
mount(parent: HTMLElement, afterNode: Node | null) {
|
|
||||||
this.mountNode(document.createTextNode(toText(this.text)), parent, afterNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
patch(other: VText) {
|
|
||||||
const text2 = other.text;
|
|
||||||
if (this.text !== text2) {
|
|
||||||
characterDataSetData.call(this.el!, toText(text2));
|
|
||||||
this.text = text2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class VComment extends VSimpleNode {
|
|
||||||
mount(parent: HTMLElement, afterNode: Node | null) {
|
|
||||||
this.mountNode(document.createComment(toText(this.text)), parent, afterNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
patch() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function text(str: string): VNode<VText> {
|
export function text(str: string): VNode<VText> {
|
||||||
return new VText(str);
|
return new VText(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function comment(str: string): VNode<VComment> {
|
|
||||||
return new VComment(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function toText(value: any): string {
|
export function toText(value: any): string {
|
||||||
switch (typeof value) {
|
switch (typeof value) {
|
||||||
case "string":
|
case "string":
|
||||||
|
|||||||
+132
-196
@@ -19,10 +19,9 @@ import {
|
|||||||
ASTTSet,
|
ASTTSet,
|
||||||
ASTTranslation,
|
ASTTranslation,
|
||||||
ASTType,
|
ASTType,
|
||||||
ASTTPortal,
|
|
||||||
} from "./parser";
|
} from "./parser";
|
||||||
|
|
||||||
type BlockType = "block" | "text" | "multi" | "list" | "html" | "comment";
|
type BlockType = "block" | "text" | "multi" | "list" | "html";
|
||||||
|
|
||||||
export interface Config {
|
export interface Config {
|
||||||
translateFn?: (s: string) => string;
|
translateFn?: (s: string) => string;
|
||||||
@@ -32,7 +31,6 @@ export interface Config {
|
|||||||
|
|
||||||
export interface CodeGenOptions extends Config {
|
export interface CodeGenOptions extends Config {
|
||||||
hasSafeContext?: boolean;
|
hasSafeContext?: boolean;
|
||||||
name?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// using a non-html document so that <inner/outer>HTML serializes as XML instead
|
// using a non-html document so that <inner/outer>HTML serializes as XML instead
|
||||||
@@ -45,11 +43,7 @@ const xmlDoc = document.implementation.createDocument(null, null, null);
|
|||||||
|
|
||||||
class BlockDescription {
|
class BlockDescription {
|
||||||
static nextBlockId = 1;
|
static nextBlockId = 1;
|
||||||
static nextDataIds: { [key: string]: number } = {};
|
static nextDataId = 1;
|
||||||
static generateId(prefix: string) {
|
|
||||||
this.nextDataIds[prefix] = (this.nextDataIds[prefix] || 0) + 1;
|
|
||||||
return prefix + this.nextDataIds[prefix];
|
|
||||||
}
|
|
||||||
|
|
||||||
varName: string;
|
varName: string;
|
||||||
blockName: string;
|
blockName: string;
|
||||||
@@ -65,19 +59,17 @@ class BlockDescription {
|
|||||||
type: BlockType;
|
type: BlockType;
|
||||||
parentVar: string = "";
|
parentVar: string = "";
|
||||||
id: number;
|
id: number;
|
||||||
deepRemove: boolean;
|
|
||||||
|
|
||||||
constructor(target: CodeTarget, type: BlockType, deepRemove: boolean = false) {
|
constructor(target: CodeTarget, type: BlockType) {
|
||||||
this.id = BlockDescription.nextBlockId++;
|
this.id = BlockDescription.nextBlockId++;
|
||||||
this.varName = "b" + this.id;
|
this.varName = "b" + this.id;
|
||||||
this.blockName = "block" + this.id;
|
this.blockName = "block" + this.id;
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.deepRemove = deepRemove;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
insertData(str: string, prefix: string = "d"): number {
|
insertData(str: string): number {
|
||||||
const id = BlockDescription.generateId(prefix);
|
const id = "d" + BlockDescription.nextDataId++;
|
||||||
this.target.addLine(`let ${id} = ${str};`);
|
this.target.addLine(`let ${id} = ${str};`);
|
||||||
return this.data.push(id) - 1;
|
return this.data.push(id) - 1;
|
||||||
}
|
}
|
||||||
@@ -102,7 +94,7 @@ class BlockDescription {
|
|||||||
}
|
}
|
||||||
return `${this.blockName}(${params})`;
|
return `${this.blockName}(${params})`;
|
||||||
} else if (this.type === "list") {
|
} else if (this.type === "list") {
|
||||||
return `list(c_block${this.id}${this.deepRemove ? ", true" : ""})`;
|
return `list(c_block${this.id})`;
|
||||||
}
|
}
|
||||||
return expr;
|
return expr;
|
||||||
}
|
}
|
||||||
@@ -150,10 +142,6 @@ class CodeTarget {
|
|||||||
code: string[] = [];
|
code: string[] = [];
|
||||||
hasRoot = false;
|
hasRoot = false;
|
||||||
hasCache = false;
|
hasCache = false;
|
||||||
hasRef: boolean = false;
|
|
||||||
// maps ref name to [id, expr]
|
|
||||||
refInfo: { [name: string]: [string, string] } = {};
|
|
||||||
shouldProtectScope: boolean = false;
|
|
||||||
|
|
||||||
constructor(name: string) {
|
constructor(name: string) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -167,34 +155,6 @@ class CodeTarget {
|
|||||||
this.code.splice(idx, 0, prefix + line);
|
this.code.splice(idx, 0, prefix + line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
generateCode(): string {
|
|
||||||
let result: string[] = [];
|
|
||||||
result.push(`function ${this.name}(ctx, node, key = "") {`);
|
|
||||||
if (this.hasRef) {
|
|
||||||
result.push(` const refs = ctx.__owl__.refs;`);
|
|
||||||
for (let name in this.refInfo) {
|
|
||||||
const [id, expr] = this.refInfo[name];
|
|
||||||
result.push(` const ${id} = ${expr};`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.shouldProtectScope) {
|
|
||||||
result.push(` ctx = Object.create(ctx);`);
|
|
||||||
result.push(` ctx[isBoundary] = 1`);
|
|
||||||
}
|
|
||||||
if (this.hasCache) {
|
|
||||||
result.push(` let cache = ctx.cache || {};`);
|
|
||||||
result.push(` let nextCache = ctx.cache = {};`);
|
|
||||||
}
|
|
||||||
for (let line of this.code) {
|
|
||||||
result.push(line);
|
|
||||||
}
|
|
||||||
if (!this.hasRoot) {
|
|
||||||
result.push(`return text('');`);
|
|
||||||
}
|
|
||||||
result.push(`}`);
|
|
||||||
return result.join("\n ");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const TRANSLATABLE_ATTRS = ["label", "title", "placeholder", "alt"];
|
const TRANSLATABLE_ATTRS = ["label", "title", "placeholder", "alt"];
|
||||||
@@ -202,34 +162,36 @@ const translationRE = /^(\s*)([\s\S]+?)(\s*)$/;
|
|||||||
|
|
||||||
export class CodeGenerator {
|
export class CodeGenerator {
|
||||||
blocks: BlockDescription[] = [];
|
blocks: BlockDescription[] = [];
|
||||||
ids: { [key: string]: number } = {};
|
nextId = 1;
|
||||||
nextBlockId = 1;
|
nextBlockId = 1;
|
||||||
|
shouldProtectScope: boolean = false;
|
||||||
|
shouldDefineAssign: boolean = false;
|
||||||
hasSafeContext: boolean;
|
hasSafeContext: boolean;
|
||||||
|
hasRef: boolean = false;
|
||||||
isDebug: boolean = false;
|
isDebug: boolean = false;
|
||||||
targets: CodeTarget[] = [];
|
functions: CodeTarget[] = [];
|
||||||
target = new CodeTarget("template");
|
target = new CodeTarget("main");
|
||||||
templateName?: string;
|
templateName: string;
|
||||||
dev: boolean;
|
dev: boolean;
|
||||||
translateFn: (s: string) => string;
|
translateFn: (s: string) => string;
|
||||||
translatableAttributes: string[];
|
translatableAttributes: string[];
|
||||||
ast: AST;
|
ast: AST;
|
||||||
staticCalls: { id: string; template: string }[] = [];
|
staticCalls: { id: string; template: string }[] = [];
|
||||||
helpers: Set<string> = new Set();
|
|
||||||
|
|
||||||
constructor(ast: AST, options: CodeGenOptions) {
|
constructor(name: string, ast: AST, options: CodeGenOptions) {
|
||||||
this.translateFn = options.translateFn || ((s: string) => s);
|
this.translateFn = options.translateFn || ((s: string) => s);
|
||||||
this.translatableAttributes = options.translatableAttributes || TRANSLATABLE_ATTRS;
|
this.translatableAttributes = options.translatableAttributes || TRANSLATABLE_ATTRS;
|
||||||
this.hasSafeContext = options.hasSafeContext || false;
|
this.hasSafeContext = options.hasSafeContext || false;
|
||||||
this.dev = options.dev || false;
|
this.dev = options.dev || false;
|
||||||
this.ast = ast;
|
this.ast = ast;
|
||||||
this.templateName = options.name;
|
this.templateName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
generateCode(): string {
|
generateCode(): string {
|
||||||
const ast = this.ast;
|
const ast = this.ast;
|
||||||
this.isDebug = ast.type === ASTType.TDebug;
|
this.isDebug = ast.type === ASTType.TDebug;
|
||||||
BlockDescription.nextBlockId = 1;
|
BlockDescription.nextBlockId = 1;
|
||||||
BlockDescription.nextDataIds = {};
|
BlockDescription.nextDataId = 1;
|
||||||
this.compileAST(ast, {
|
this.compileAST(ast, {
|
||||||
block: null,
|
block: null,
|
||||||
index: 0,
|
index: 0,
|
||||||
@@ -238,58 +200,68 @@ export class CodeGenerator {
|
|||||||
translate: true,
|
translate: true,
|
||||||
tKeyExpr: null,
|
tKeyExpr: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let mainCode = this.target.code;
|
||||||
|
this.target.code = [];
|
||||||
|
this.target.indentLevel = 0;
|
||||||
// define blocks and utility functions
|
// define blocks and utility functions
|
||||||
let mainCode = [
|
this.addLine(`let { text, createBlock, list, multi, html, toggler, component } = bdom;`);
|
||||||
` let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;`,
|
this.addLine(
|
||||||
];
|
`let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;`
|
||||||
if (this.helpers.size) {
|
);
|
||||||
mainCode.push(`let { ${[...this.helpers].join(", ")} } = helpers;`);
|
if (this.shouldDefineAssign) {
|
||||||
}
|
this.addLine(`let assign = Object.assign;`);
|
||||||
if (this.templateName) {
|
|
||||||
mainCode.push(`// Template name: "${this.templateName}"`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let { id, template } of this.staticCalls) {
|
for (let { id, template } of this.staticCalls) {
|
||||||
mainCode.push(`const ${id} = getTemplate(${template});`);
|
this.addLine(`const ${id} = getTemplate(${template});`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const deepRemove = "deepRemove" in this.ast ? this.ast.deepRemove : false;
|
|
||||||
|
|
||||||
// define all blocks
|
// define all blocks
|
||||||
if (this.blocks.length) {
|
if (this.blocks.length) {
|
||||||
mainCode.push(``);
|
this.addLine(``);
|
||||||
for (let block of this.blocks) {
|
for (let block of this.blocks) {
|
||||||
if (block.dom) {
|
if (block.dom) {
|
||||||
let xmlString = block.asXmlString();
|
let xmlString = block.asXmlString();
|
||||||
if (block.dynamicTagName) {
|
if (block.dynamicTagName) {
|
||||||
xmlString = xmlString.replace(/^<\w+/, `<\${tag || '${block.dom.nodeName}'}`);
|
xmlString = xmlString.replace(/^<\w+/, `<\${tag || '${block.dom.nodeName}'}`);
|
||||||
xmlString = xmlString.replace(/\w+>$/, `\${tag || '${block.dom.nodeName}'}>`);
|
xmlString = xmlString.replace(/\w+>$/, `\${tag || '${block.dom.nodeName}'}>`);
|
||||||
mainCode.push(
|
this.addLine(`let ${block.blockName} = tag => createBlock(\`${xmlString}\`);`);
|
||||||
`let ${block.blockName} = tag => createBlock(\`${xmlString}\`${
|
|
||||||
deepRemove ? ", true" : ""
|
|
||||||
});`
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
mainCode.push(
|
this.addLine(`let ${block.blockName} = createBlock(\`${xmlString}\`);`);
|
||||||
`let ${block.blockName} = createBlock(\`${xmlString}\`${deepRemove ? ", true" : ""});`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// define all slots/defaultcontent function
|
// define all slots
|
||||||
if (this.targets.length) {
|
for (let fn of this.functions) {
|
||||||
for (let fn of this.targets) {
|
this.generateFunctions(fn);
|
||||||
mainCode.push("");
|
|
||||||
mainCode = mainCode.concat(fn.generateCode());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate main code
|
// // generate main code
|
||||||
mainCode.push("");
|
this.target.indentLevel = 0;
|
||||||
mainCode = mainCode.concat("return " + this.target.generateCode());
|
this.addLine(``);
|
||||||
const code = mainCode.join("\n ");
|
this.addLine(`return function template(ctx, node, key = "") {`);
|
||||||
|
if (this.hasRef) {
|
||||||
|
this.addLine(` const refs = ctx.__owl__.refs;`);
|
||||||
|
}
|
||||||
|
if (this.shouldProtectScope) {
|
||||||
|
this.addLine(` ctx = Object.create(ctx);`);
|
||||||
|
this.addLine(` ctx[isBoundary] = 1`);
|
||||||
|
}
|
||||||
|
if (this.target.hasCache) {
|
||||||
|
this.addLine(` let cache = ctx.cache || {};`);
|
||||||
|
this.addLine(` let nextCache = ctx.cache = {};`);
|
||||||
|
}
|
||||||
|
for (let line of mainCode) {
|
||||||
|
this.addLine(line);
|
||||||
|
}
|
||||||
|
if (!this.target.hasRoot) {
|
||||||
|
throw new Error("missing root block");
|
||||||
|
}
|
||||||
|
this.addLine("}");
|
||||||
|
const code = this.target.code.join("\n");
|
||||||
|
|
||||||
if (this.isDebug) {
|
if (this.isDebug) {
|
||||||
const msg = `[Owl Debug]\n${code}`;
|
const msg = `[Owl Debug]\n${code}`;
|
||||||
@@ -298,25 +270,16 @@ export class CodeGenerator {
|
|||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
compileInNewTarget(prefix: string, ast: AST, ctx: Context): string {
|
|
||||||
const name = this.generateId(prefix);
|
|
||||||
const initialTarget = this.target;
|
|
||||||
const target = new CodeTarget(name);
|
|
||||||
this.targets.push(target);
|
|
||||||
this.target = target;
|
|
||||||
const subCtx: Context = createContext(ctx);
|
|
||||||
this.compileAST(ast, subCtx);
|
|
||||||
this.target = initialTarget;
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
addLine(line: string) {
|
addLine(line: string) {
|
||||||
this.target.addLine(line);
|
this.target.addLine(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
generateId(prefix: string = ""): string {
|
generateId(prefix: string = ""): string {
|
||||||
this.ids[prefix] = (this.ids[prefix] || 0) + 1;
|
return `${prefix}${this.nextId++}`;
|
||||||
return prefix + this.ids[prefix];
|
}
|
||||||
|
|
||||||
|
generateBlockName(): string {
|
||||||
|
return `block${this.blocks.length + 1}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
insertAnchor(block: BlockDescription) {
|
insertAnchor(block: BlockDescription) {
|
||||||
@@ -328,11 +291,10 @@ export class CodeGenerator {
|
|||||||
createBlock(
|
createBlock(
|
||||||
parentBlock: BlockDescription | null,
|
parentBlock: BlockDescription | null,
|
||||||
type: BlockType,
|
type: BlockType,
|
||||||
ctx: Context,
|
ctx: Context
|
||||||
deepRemove: boolean = false
|
|
||||||
): BlockDescription {
|
): BlockDescription {
|
||||||
const hasRoot = this.target.hasRoot;
|
const hasRoot = this.target.hasRoot;
|
||||||
const block = new BlockDescription(this.target, type, deepRemove);
|
const block = new BlockDescription(this.target, type);
|
||||||
if (!hasRoot && !ctx.preventRoot) {
|
if (!hasRoot && !ctx.preventRoot) {
|
||||||
this.target.hasRoot = true;
|
this.target.hasRoot = true;
|
||||||
block.isRoot = true;
|
block.isRoot = true;
|
||||||
@@ -354,7 +316,6 @@ export class CodeGenerator {
|
|||||||
if (tKeyExpr) {
|
if (tKeyExpr) {
|
||||||
keyArg = `${tKeyExpr} + ${keyArg}`;
|
keyArg = `${tKeyExpr} + ${keyArg}`;
|
||||||
}
|
}
|
||||||
this.helpers.add("withKey");
|
|
||||||
this.addLine(`${block.parentVar}[${ctx.index}] = withKey(${blockExpr}, ${keyArg});`);
|
this.addLine(`${block.parentVar}[${ctx.index}] = withKey(${blockExpr}, ${keyArg});`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -370,6 +331,18 @@ export class CodeGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generateFunctions(fn: CodeTarget) {
|
||||||
|
this.addLine("");
|
||||||
|
this.addLine(`function ${fn.name}(ctx, node, key) {`);
|
||||||
|
if (fn.hasCache) {
|
||||||
|
this.addLine(`let cache = ctx.cache || {};`);
|
||||||
|
this.addLine(`let nextCache = ctx.cache = {};`);
|
||||||
|
}
|
||||||
|
for (let line of fn.code) {
|
||||||
|
this.addLine(line);
|
||||||
|
}
|
||||||
|
this.addLine(`}`);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Captures variables that are used inside of an expression. This is useful
|
* Captures variables that are used inside of an expression. This is useful
|
||||||
* because in compiled code, almost all variables are accessed through the ctx
|
* because in compiled code, almost all variables are accessed through the ctx
|
||||||
@@ -457,8 +430,6 @@ export class CodeGenerator {
|
|||||||
case ASTType.TTranslation:
|
case ASTType.TTranslation:
|
||||||
this.compileTTranslation(ast, ctx);
|
this.compileTTranslation(ast, ctx);
|
||||||
break;
|
break;
|
||||||
case ASTType.TPortal:
|
|
||||||
this.compileTPortal(ast, ctx);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,14 +450,13 @@ export class CodeGenerator {
|
|||||||
let { block, forceNewBlock } = ctx;
|
let { block, forceNewBlock } = ctx;
|
||||||
const isNewBlock = !block || forceNewBlock;
|
const isNewBlock = !block || forceNewBlock;
|
||||||
if (isNewBlock) {
|
if (isNewBlock) {
|
||||||
block = this.createBlock(block, "comment", ctx);
|
block = this.createBlock(block, "block", ctx);
|
||||||
this.insertBlock(`comment(\`${ast.value}\`)`, block, {
|
this.blocks.push(block);
|
||||||
...ctx,
|
}
|
||||||
forceNewBlock: forceNewBlock && !block,
|
const text = xmlDoc.createComment(ast.value);
|
||||||
});
|
block!.insert(text);
|
||||||
} else {
|
if (isNewBlock) {
|
||||||
const text = xmlDoc.createComment(ast.value);
|
this.insertBlock("", block!, ctx);
|
||||||
block!.insert(text);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -548,11 +518,11 @@ export class CodeGenerator {
|
|||||||
for (let key in ast.attrs) {
|
for (let key in ast.attrs) {
|
||||||
if (key.startsWith("t-attf")) {
|
if (key.startsWith("t-attf")) {
|
||||||
let expr = interpolate(ast.attrs[key]);
|
let expr = interpolate(ast.attrs[key]);
|
||||||
const idx = block!.insertData(expr, "attr");
|
const idx = block!.insertData(expr);
|
||||||
attrs["block-attribute-" + idx] = key.slice(7);
|
attrs["block-attribute-" + idx] = key.slice(7);
|
||||||
} else if (key.startsWith("t-att")) {
|
} else if (key.startsWith("t-att")) {
|
||||||
let expr = compileExpr(ast.attrs[key]);
|
let expr = compileExpr(ast.attrs[key]);
|
||||||
const idx = block!.insertData(expr, "attr");
|
const idx = block!.insertData(expr);
|
||||||
if (key === "t-att") {
|
if (key === "t-att") {
|
||||||
attrs[`block-attributes`] = String(idx);
|
attrs[`block-attributes`] = String(idx);
|
||||||
} else {
|
} else {
|
||||||
@@ -568,36 +538,24 @@ export class CodeGenerator {
|
|||||||
// event handlers
|
// event handlers
|
||||||
for (let ev in ast.on) {
|
for (let ev in ast.on) {
|
||||||
const name = this.generateHandlerCode(ev, ast.on[ev]);
|
const name = this.generateHandlerCode(ev, ast.on[ev]);
|
||||||
const idx = block!.insertData(name, "hdlr");
|
const idx = block!.insertData(name);
|
||||||
attrs[`block-handler-${idx}`] = ev;
|
attrs[`block-handler-${idx}`] = ev;
|
||||||
}
|
}
|
||||||
|
|
||||||
// t-ref
|
// t-ref
|
||||||
if (ast.ref) {
|
if (ast.ref) {
|
||||||
this.target.hasRef = true;
|
this.hasRef = true;
|
||||||
const isDynamic = INTERP_REGEXP.test(ast.ref);
|
const isDynamic = INTERP_REGEXP.test(ast.ref);
|
||||||
if (isDynamic) {
|
if (isDynamic) {
|
||||||
const str = ast.ref.replace(
|
const str = ast.ref.replace(
|
||||||
INTERP_REGEXP,
|
INTERP_REGEXP,
|
||||||
(expr) => "${" + this.captureExpression(expr.slice(2, -2), true) + "}"
|
(expr) => "${" + this.captureExpression(expr.slice(2, -2), true) + "}"
|
||||||
);
|
);
|
||||||
const idx = block!.insertData(`(el) => refs[\`${str}\`] = el`, "ref");
|
const idx = block!.insertData(`(el) => refs[\`${str}\`] = el`);
|
||||||
attrs["block-ref"] = String(idx);
|
attrs["block-ref"] = String(idx);
|
||||||
} else {
|
} else {
|
||||||
let name = ast.ref;
|
const idx = block!.insertData(`(el) => refs[\`${ast.ref}\`] = el`);
|
||||||
if (name in this.target.refInfo) {
|
attrs["block-ref"] = String(idx);
|
||||||
// ref has already been defined
|
|
||||||
this.helpers.add("multiRefSetter");
|
|
||||||
const info = this.target.refInfo[name];
|
|
||||||
const index = block!.data.push(info[0]) - 1;
|
|
||||||
attrs["block-ref"] = String(index);
|
|
||||||
info[1] = `multiRefSetter(refs, \`${name}\`)`;
|
|
||||||
} else {
|
|
||||||
let id = this.generateId("ref");
|
|
||||||
this.target.refInfo[name] = [id, `(el) => refs[\`${name}\`] = el`];
|
|
||||||
const index = block!.data.push(id) - 1;
|
|
||||||
attrs["block-ref"] = String(index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,22 +579,18 @@ export class CodeGenerator {
|
|||||||
|
|
||||||
let idx: number;
|
let idx: number;
|
||||||
if (specialInitTargetAttr) {
|
if (specialInitTargetAttr) {
|
||||||
idx = block!.insertData(
|
idx = block!.insertData(`${baseExpression}[${expression}] === '${attrs[targetAttr]}'`);
|
||||||
`${baseExpression}[${expression}] === '${attrs[targetAttr]}'`,
|
|
||||||
"attr"
|
|
||||||
);
|
|
||||||
attrs[`block-attribute-${idx}`] = specialInitTargetAttr;
|
attrs[`block-attribute-${idx}`] = specialInitTargetAttr;
|
||||||
} else {
|
} else {
|
||||||
idx = block!.insertData(`${baseExpression}[${expression}]`, "attr");
|
idx = block!.insertData(`${baseExpression}[${expression}]`);
|
||||||
attrs[`block-attribute-${idx}`] = targetAttr;
|
attrs[`block-attribute-${idx}`] = targetAttr;
|
||||||
}
|
}
|
||||||
this.helpers.add("toNumber");
|
|
||||||
let valueCode = `ev.target.${targetAttr}`;
|
let valueCode = `ev.target.${targetAttr}`;
|
||||||
valueCode = shouldTrim ? `${valueCode}.trim()` : valueCode;
|
valueCode = shouldTrim ? `${valueCode}.trim()` : valueCode;
|
||||||
valueCode = shouldNumberize ? `toNumber(${valueCode})` : valueCode;
|
valueCode = shouldNumberize ? `toNumber(${valueCode})` : valueCode;
|
||||||
|
|
||||||
const handler = `[(ev) => { bExpr${id}[${expression}] = ${valueCode}; }]`;
|
const handler = `[(ev) => { bExpr${id}[${expression}] = ${valueCode}; }]`;
|
||||||
idx = block!.insertData(handler, "hdlr");
|
idx = block!.insertData(handler);
|
||||||
attrs[`block-handler-${idx}`] = eventType;
|
attrs[`block-handler-${idx}`] = eventType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -658,7 +612,6 @@ export class CodeGenerator {
|
|||||||
index: block!.childNumber,
|
index: block!.childNumber,
|
||||||
forceNewBlock: false,
|
forceNewBlock: false,
|
||||||
isLast: ctx.isLast && i === children.length - 1,
|
isLast: ctx.isLast && i === children.length - 1,
|
||||||
tKeyExpr: ctx.tKeyExpr,
|
|
||||||
});
|
});
|
||||||
this.compileAST(child, subCtx);
|
this.compileAST(child, subCtx);
|
||||||
}
|
}
|
||||||
@@ -688,12 +641,10 @@ export class CodeGenerator {
|
|||||||
let { block, forceNewBlock } = ctx;
|
let { block, forceNewBlock } = ctx;
|
||||||
let expr: string;
|
let expr: string;
|
||||||
if (ast.expr === "0") {
|
if (ast.expr === "0") {
|
||||||
this.helpers.add("zero");
|
|
||||||
expr = `ctx[zero]`;
|
expr = `ctx[zero]`;
|
||||||
} else {
|
} else {
|
||||||
expr = compileExpr(ast.expr);
|
expr = compileExpr(ast.expr);
|
||||||
if (ast.defaultValue) {
|
if (ast.defaultValue) {
|
||||||
this.helpers.add("withDefault");
|
|
||||||
expr = `withDefault(${expr}, \`${ast.defaultValue}\`)`;
|
expr = `withDefault(${expr}, \`${ast.defaultValue}\`)`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -701,7 +652,7 @@ export class CodeGenerator {
|
|||||||
block = this.createBlock(block, "text", ctx);
|
block = this.createBlock(block, "text", ctx);
|
||||||
this.insertBlock(`text(${expr})`, block, { ...ctx, forceNewBlock: forceNewBlock && !block });
|
this.insertBlock(`text(${expr})`, block, { ...ctx, forceNewBlock: forceNewBlock && !block });
|
||||||
} else {
|
} else {
|
||||||
const idx = block.insertData(expr, "txt");
|
const idx = block.insertData(expr);
|
||||||
const text = xmlDoc.createElement(`block-text-${idx}`);
|
const text = xmlDoc.createElement(`block-text-${idx}`);
|
||||||
block.insert(text);
|
block.insert(text);
|
||||||
}
|
}
|
||||||
@@ -713,13 +664,11 @@ export class CodeGenerator {
|
|||||||
this.insertAnchor(block);
|
this.insertAnchor(block);
|
||||||
}
|
}
|
||||||
block = this.createBlock(block, "html", ctx);
|
block = this.createBlock(block, "html", ctx);
|
||||||
this.helpers.add(ast.expr === "0" ? "zero" : "safeOutput");
|
|
||||||
let expr = ast.expr === "0" ? "ctx[zero]" : `safeOutput(${compileExpr(ast.expr)})`;
|
let expr = ast.expr === "0" ? "ctx[zero]" : `safeOutput(${compileExpr(ast.expr)})`;
|
||||||
if (ast.body) {
|
if (ast.body) {
|
||||||
const nextId = BlockDescription.nextBlockId;
|
const nextId = BlockDescription.nextBlockId;
|
||||||
const subCtx: Context = createContext(ctx);
|
const subCtx: Context = createContext(ctx);
|
||||||
this.compileAST({ type: ASTType.Multi, content: ast.body, deepRemove: false }, subCtx);
|
this.compileAST({ type: ASTType.Multi, content: ast.body }, subCtx);
|
||||||
this.helpers.add("withDefault");
|
|
||||||
expr = `withDefault(${expr}, b${nextId})`;
|
expr = `withDefault(${expr}, b${nextId})`;
|
||||||
}
|
}
|
||||||
this.insertBlock(`${expr}`, block, ctx);
|
this.insertBlock(`${expr}`, block, ctx);
|
||||||
@@ -779,7 +728,7 @@ export class CodeGenerator {
|
|||||||
|
|
||||||
// note: this part is duplicated from end of compilemulti:
|
// note: this part is duplicated from end of compilemulti:
|
||||||
const args = block!.children.map((c) => c.varName).join(", ");
|
const args = block!.children.map((c) => c.varName).join(", ");
|
||||||
this.insertBlock(`multi([${args}]${ast.deepRemove ? ", true" : ""})`, block!, ctx)!;
|
this.insertBlock(`multi([${args}])`, block!, ctx)!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -788,7 +737,7 @@ export class CodeGenerator {
|
|||||||
if (block) {
|
if (block) {
|
||||||
this.insertAnchor(block);
|
this.insertAnchor(block);
|
||||||
}
|
}
|
||||||
block = this.createBlock(block, "list", ctx, ast.deepRemove);
|
block = this.createBlock(block, "list", ctx);
|
||||||
this.target.loopLevel++;
|
this.target.loopLevel++;
|
||||||
const loopVar = `i${this.target.loopLevel}`;
|
const loopVar = `i${this.target.loopLevel}`;
|
||||||
this.addLine(`ctx = Object.create(ctx);`);
|
this.addLine(`ctx = Object.create(ctx);`);
|
||||||
@@ -796,7 +745,6 @@ export class CodeGenerator {
|
|||||||
const keys = `k_block${block.id}`;
|
const keys = `k_block${block.id}`;
|
||||||
const l = `l_block${block.id}`;
|
const l = `l_block${block.id}`;
|
||||||
const c = `c_block${block.id}`;
|
const c = `c_block${block.id}`;
|
||||||
this.helpers.add("prepareList");
|
|
||||||
this.addLine(
|
this.addLine(
|
||||||
`const [${keys}, ${vals}, ${l}, ${c}] = prepareList(${compileExpr(ast.collection)});`
|
`const [${keys}, ${vals}, ${l}, ${c}] = prepareList(${compileExpr(ast.collection)});`
|
||||||
);
|
);
|
||||||
@@ -830,6 +778,7 @@ export class CodeGenerator {
|
|||||||
let id: string;
|
let id: string;
|
||||||
if (ast.memo) {
|
if (ast.memo) {
|
||||||
this.target.hasCache = true;
|
this.target.hasCache = true;
|
||||||
|
this.shouldDefineAssign = true;
|
||||||
id = this.generateId();
|
id = this.generateId();
|
||||||
this.addLine(`let memo${id} = ${compileExpr(ast.memo)}`);
|
this.addLine(`let memo${id} = ${compileExpr(ast.memo)}`);
|
||||||
this.addLine(`let vnode${id} = cache[key${this.target.loopLevel}];`);
|
this.addLine(`let vnode${id} = cache[key${this.target.loopLevel}];`);
|
||||||
@@ -850,9 +799,7 @@ export class CodeGenerator {
|
|||||||
this.compileAST(ast.body, subCtx);
|
this.compileAST(ast.body, subCtx);
|
||||||
if (ast.memo) {
|
if (ast.memo) {
|
||||||
this.addLine(
|
this.addLine(
|
||||||
`nextCache[key${
|
`nextCache[key${this.target.loopLevel}] = assign(${c}[${loopVar}], {memo: memo${id!}});`
|
||||||
this.target.loopLevel
|
|
||||||
}] = Object.assign(${c}[${loopVar}], {memo: memo${id!}});`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.target.indentLevel--;
|
this.target.indentLevel--;
|
||||||
@@ -923,7 +870,7 @@ export class CodeGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const args = block!.children.map((c) => c.varName).join(", ");
|
const args = block!.children.map((c) => c.varName).join(", ");
|
||||||
this.insertBlock(`multi([${args}]${ast.deepRemove ? ", true" : ""})`, block!, ctx)!;
|
this.insertBlock(`multi([${args}])`, block!, ctx)!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -932,12 +879,10 @@ export class CodeGenerator {
|
|||||||
if (ast.body) {
|
if (ast.body) {
|
||||||
this.addLine(`ctx = Object.create(ctx);`);
|
this.addLine(`ctx = Object.create(ctx);`);
|
||||||
this.addLine(`ctx[isBoundary] = 1;`);
|
this.addLine(`ctx[isBoundary] = 1;`);
|
||||||
this.helpers.add("isBoundary");
|
|
||||||
const nextId = BlockDescription.nextBlockId;
|
const nextId = BlockDescription.nextBlockId;
|
||||||
const subCtx: Context = createContext(ctx, { preventRoot: true });
|
const subCtx: Context = createContext(ctx, { preventRoot: true });
|
||||||
this.compileAST({ type: ASTType.Multi, content: ast.body, deepRemove: false }, subCtx);
|
this.compileAST({ type: ASTType.Multi, content: ast.body }, subCtx);
|
||||||
if (nextId !== BlockDescription.nextBlockId) {
|
if (nextId !== BlockDescription.nextBlockId) {
|
||||||
this.helpers.add("zero");
|
|
||||||
this.addLine(`ctx[zero] = b${nextId};`);
|
this.addLine(`ctx[zero] = b${nextId};`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -953,14 +898,12 @@ export class CodeGenerator {
|
|||||||
const templateVar = this.generateId("template");
|
const templateVar = this.generateId("template");
|
||||||
this.addLine(`const ${templateVar} = ${subTemplate};`);
|
this.addLine(`const ${templateVar} = ${subTemplate};`);
|
||||||
block = this.createBlock(block, "multi", ctx);
|
block = this.createBlock(block, "multi", ctx);
|
||||||
this.helpers.add("call");
|
this.insertBlock(`call(${templateVar}, ctx, node, ${key})`, block!, {
|
||||||
this.insertBlock(`call(this, ${templateVar}, ctx, node, ${key})`, block!, {
|
|
||||||
...ctx,
|
...ctx,
|
||||||
forceNewBlock: !block,
|
forceNewBlock: !block,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const id = this.generateId(`callTemplate_`);
|
const id = this.generateId(`callTemplate_`);
|
||||||
this.helpers.add("getTemplate");
|
|
||||||
this.staticCalls.push({ id, template: subTemplate });
|
this.staticCalls.push({ id, template: subTemplate });
|
||||||
block = this.createBlock(block, "multi", ctx);
|
block = this.createBlock(block, "multi", ctx);
|
||||||
this.insertBlock(`${id}.call(this, ctx, node, ${key})`, block!, {
|
this.insertBlock(`${id}.call(this, ctx, node, ${key})`, block!, {
|
||||||
@@ -985,15 +928,13 @@ export class CodeGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
compileTSet(ast: ASTTSet, ctx: Context) {
|
compileTSet(ast: ASTTSet, ctx: Context) {
|
||||||
this.target.shouldProtectScope = true;
|
this.shouldProtectScope = true;
|
||||||
this.helpers.add("isBoundary").add("withDefault");
|
|
||||||
const expr = ast.value ? compileExpr(ast.value || "") : "null";
|
const expr = ast.value ? compileExpr(ast.value || "") : "null";
|
||||||
if (ast.body) {
|
if (ast.body) {
|
||||||
this.helpers.add("LazyValue");
|
const subCtx: Context = createContext(ctx);
|
||||||
const bodyAst: AST = { type: ASTType.Multi, content: ast.body, deepRemove: false };
|
const nextId = `b${BlockDescription.nextBlockId}`;
|
||||||
const name = this.compileInNewTarget("value", bodyAst, ctx);
|
this.compileAST({ type: ASTType.Multi, content: ast.body }, subCtx);
|
||||||
let value = `new LazyValue(${name}, ctx, node)`;
|
const value = ast.value ? (nextId ? `withDefault(${expr}, ${nextId})` : expr) : nextId;
|
||||||
value = ast.value ? (value ? `withDefault(${expr}, ${value})` : expr) : value;
|
|
||||||
this.addLine(`ctx[\`${ast.name}\`] = ${value};`);
|
this.addLine(`ctx[\`${ast.name}\`] = ${value};`);
|
||||||
} else {
|
} else {
|
||||||
let value: string;
|
let value: string;
|
||||||
@@ -1006,7 +947,6 @@ export class CodeGenerator {
|
|||||||
} else {
|
} else {
|
||||||
value = expr;
|
value = expr;
|
||||||
}
|
}
|
||||||
this.helpers.add("setContextValue");
|
|
||||||
this.addLine(`setContextValue(ctx, "${ast.name}", ${value});`);
|
this.addLine(`setContextValue(ctx, "${ast.name}", ${value});`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1025,19 +965,10 @@ export class CodeGenerator {
|
|||||||
// props
|
// props
|
||||||
const props: string[] = [];
|
const props: string[] = [];
|
||||||
let hasSlotsProp = false;
|
let hasSlotsProp = false;
|
||||||
for (let propName in ast.props) {
|
for (let p in ast.props) {
|
||||||
let propValue = this.captureExpression(ast.props[propName]) || undefined;
|
const propName = /^[a-z_]+$/i.test(p) ? p : `'${p}'`;
|
||||||
if (propName.includes(".")) {
|
props.push(`${propName}: ${this.captureExpression(ast.props[p]) || undefined}`);
|
||||||
let [name, suffix] = propName.split(".");
|
if (p === "slots") {
|
||||||
if (suffix === "bind") {
|
|
||||||
this.helpers.add("bind");
|
|
||||||
propName = name;
|
|
||||||
propValue = `bind(ctx, ${propValue})`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
propName = /^[a-z_]+$/i.test(propName) ? propName : `'${propName}'`;
|
|
||||||
props.push(`${propName}: ${propValue}`);
|
|
||||||
if (propName === "slots") {
|
|
||||||
hasSlotsProp = true;
|
hasSlotsProp = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1049,13 +980,17 @@ export class CodeGenerator {
|
|||||||
let ctxStr = "ctx";
|
let ctxStr = "ctx";
|
||||||
if (this.target.loopLevel || !this.hasSafeContext) {
|
if (this.target.loopLevel || !this.hasSafeContext) {
|
||||||
ctxStr = this.generateId("ctx");
|
ctxStr = this.generateId("ctx");
|
||||||
this.helpers.add("capture");
|
|
||||||
this.addLine(`const ${ctxStr} = capture(ctx);`);
|
this.addLine(`const ${ctxStr} = capture(ctx);`);
|
||||||
}
|
}
|
||||||
let slotStr: string[] = [];
|
let slotStr: string[] = [];
|
||||||
|
const initialTarget = this.target;
|
||||||
for (let slotName in ast.slots) {
|
for (let slotName in ast.slots) {
|
||||||
const slotAst = ast.slots[slotName].content;
|
let name = this.generateId("slot");
|
||||||
const name = this.compileInNewTarget("slot", slotAst, ctx);
|
const slot = new CodeTarget(name);
|
||||||
|
this.functions.push(slot);
|
||||||
|
this.target = slot;
|
||||||
|
const subCtx: Context = createContext(ctx);
|
||||||
|
this.compileAST(ast.slots[slotName].content, subCtx);
|
||||||
const params = [`__render: ${name}, __ctx: ${ctxStr}`];
|
const params = [`__render: ${name}, __ctx: ${ctxStr}`];
|
||||||
const scope = ast.slots[slotName].scope;
|
const scope = ast.slots[slotName].scope;
|
||||||
if (scope) {
|
if (scope) {
|
||||||
@@ -1067,8 +1002,14 @@ export class CodeGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const slotInfo = `{${params.join(", ")}}`;
|
const slotInfo = `{${params.join(", ")}}`;
|
||||||
slotStr.push(`'${slotName}': ${slotInfo}`);
|
if (this.hasRef) {
|
||||||
|
slot.code.unshift(` const refs = ctx.__owl__.refs`);
|
||||||
|
slotStr.push(`'${slotName}': ${slotInfo}`);
|
||||||
|
} else {
|
||||||
|
slotStr.push(`'${slotName}': ${slotInfo}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
this.target = initialTarget;
|
||||||
slotDef = `{${slotStr.join(", ")}}`;
|
slotDef = `{${slotStr.join(", ")}}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1131,7 +1072,6 @@ export class CodeGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
compileTSlot(ast: ASTSlot, ctx: Context) {
|
compileTSlot(ast: ASTSlot, ctx: Context) {
|
||||||
this.helpers.add("callSlot");
|
|
||||||
let { block } = ctx;
|
let { block } = ctx;
|
||||||
let blockString: string;
|
let blockString: string;
|
||||||
let slotName;
|
let slotName;
|
||||||
@@ -1153,7 +1093,14 @@ export class CodeGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ast.defaultContent) {
|
if (ast.defaultContent) {
|
||||||
const name = this.compileInNewTarget("defaultContent", ast.defaultContent, ctx);
|
let name = this.generateId("defaultContent");
|
||||||
|
const slot = new CodeTarget(name);
|
||||||
|
this.functions.push(slot);
|
||||||
|
const initialTarget = this.target;
|
||||||
|
const subCtx: Context = createContext(ctx);
|
||||||
|
this.target = slot;
|
||||||
|
this.compileAST(ast.defaultContent, subCtx);
|
||||||
|
this.target = initialTarget;
|
||||||
blockString = `callSlot(ctx, node, key, ${slotName}, ${dynamic}, ${scope}, ${name})`;
|
blockString = `callSlot(ctx, node, key, ${slotName}, ${dynamic}, ${scope}, ${name})`;
|
||||||
} else {
|
} else {
|
||||||
if (dynamic) {
|
if (dynamic) {
|
||||||
@@ -1176,15 +1123,4 @@ export class CodeGenerator {
|
|||||||
this.compileAST(ast.content, Object.assign({}, ctx, { translate: false }));
|
this.compileAST(ast.content, Object.assign({}, ctx, { translate: false }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileTPortal(ast: ASTTPortal, ctx: Context) {
|
|
||||||
this.helpers.add("callPortal");
|
|
||||||
let { block } = ctx;
|
|
||||||
const name = this.compileInNewTarget("portalContent", ast.content, ctx);
|
|
||||||
const blockString = `callPortal(ctx, node, key, ${ast.target}, ${name})`;
|
|
||||||
if (block) {
|
|
||||||
this.insertAnchor(block);
|
|
||||||
}
|
|
||||||
block = this.createBlock(block, "multi", ctx);
|
|
||||||
this.insertBlock(blockString, block, { ...ctx, forceNewBlock: false });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export type TemplateFunction = (blocks: any, utils: any) => Template;
|
|||||||
interface CompileOptions extends Config {
|
interface CompileOptions extends Config {
|
||||||
name?: string;
|
name?: string;
|
||||||
}
|
}
|
||||||
|
let nextId = 1;
|
||||||
export function compile(template: string | Node, options: CompileOptions = {}): TemplateFunction {
|
export function compile(template: string | Node, options: CompileOptions = {}): TemplateFunction {
|
||||||
// parsing
|
// parsing
|
||||||
const ast = parse(template);
|
const ast = parse(template);
|
||||||
@@ -18,10 +19,12 @@ export function compile(template: string | Node, options: CompileOptions = {}):
|
|||||||
template instanceof Node
|
template instanceof Node
|
||||||
? !(template instanceof Element) || template.querySelector("[t-set], [t-call]") === null
|
? !(template instanceof Element) || template.querySelector("[t-set], [t-call]") === null
|
||||||
: !template.includes("t-set") && !template.includes("t-call");
|
: !template.includes("t-set") && !template.includes("t-call");
|
||||||
|
const name = options.name || `template_${nextId++}`;
|
||||||
|
|
||||||
// code generation
|
// code generation
|
||||||
const codeGenerator = new CodeGenerator(ast, { ...options, hasSafeContext });
|
const codeGenerator = new CodeGenerator(name, ast, { ...options, hasSafeContext });
|
||||||
const code = codeGenerator.generateCode();
|
const code = codeGenerator.generateCode();
|
||||||
|
|
||||||
// template function
|
// template function
|
||||||
return new Function("bdom, helpers", code) as TemplateFunction;
|
return new Function("bdom, helpers", code) as TemplateFunction;
|
||||||
}
|
}
|
||||||
|
|||||||
+88
-101
@@ -20,7 +20,6 @@ export const enum ASTType {
|
|||||||
TSlot,
|
TSlot,
|
||||||
TCallBlock,
|
TCallBlock,
|
||||||
TTranslation,
|
TTranslation,
|
||||||
TPortal,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ASTText {
|
export interface ASTText {
|
||||||
@@ -56,7 +55,6 @@ export interface ASTDomNode {
|
|||||||
export interface ASTMulti {
|
export interface ASTMulti {
|
||||||
type: ASTType.Multi;
|
type: ASTType.Multi;
|
||||||
content: AST[];
|
content: AST[];
|
||||||
deepRemove: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ASTTEsc {
|
export interface ASTTEsc {
|
||||||
@@ -77,7 +75,6 @@ export interface ASTTif {
|
|||||||
content: AST;
|
content: AST;
|
||||||
tElif: { condition: string; content: AST }[] | null;
|
tElif: { condition: string; content: AST }[] | null;
|
||||||
tElse: AST | null;
|
tElse: AST | null;
|
||||||
deepRemove: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ASTTSet {
|
export interface ASTTSet {
|
||||||
@@ -95,7 +92,8 @@ export interface ASTTForEach {
|
|||||||
key: string | null;
|
key: string | null;
|
||||||
body: AST;
|
body: AST;
|
||||||
memo: string;
|
memo: string;
|
||||||
deepRemove: boolean;
|
isOnlyChild: boolean;
|
||||||
|
hasNoComponent: boolean;
|
||||||
hasNoFirst: boolean;
|
hasNoFirst: boolean;
|
||||||
hasNoLast: boolean;
|
hasNoLast: boolean;
|
||||||
hasNoIndex: boolean;
|
hasNoIndex: boolean;
|
||||||
@@ -151,12 +149,6 @@ export interface ASTTranslation {
|
|||||||
content: AST | null;
|
content: AST | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ASTTPortal {
|
|
||||||
type: ASTType.TPortal;
|
|
||||||
target: string;
|
|
||||||
content: AST;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type AST =
|
export type AST =
|
||||||
| ASTText
|
| ASTText
|
||||||
| ASTComment
|
| ASTComment
|
||||||
@@ -174,8 +166,7 @@ export type AST =
|
|||||||
| ASTTCallBlock
|
| ASTTCallBlock
|
||||||
| ASTLog
|
| ASTLog
|
||||||
| ASTDebug
|
| ASTDebug
|
||||||
| ASTTranslation
|
| ASTTranslation;
|
||||||
| ASTTPortal;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Parser
|
// Parser
|
||||||
@@ -204,7 +195,6 @@ function parseNode(node: ChildNode, ctx: ParsingContext): AST | null {
|
|||||||
parseTDebugLog(node, ctx) ||
|
parseTDebugLog(node, ctx) ||
|
||||||
parseTForEach(node, ctx) ||
|
parseTForEach(node, ctx) ||
|
||||||
parseTIf(node, ctx) ||
|
parseTIf(node, ctx) ||
|
||||||
parseTPortal(node, ctx) ||
|
|
||||||
parseTCall(node, ctx) ||
|
parseTCall(node, ctx) ||
|
||||||
parseTCallBlock(node, ctx) ||
|
parseTCallBlock(node, ctx) ||
|
||||||
parseTEscNode(node, ctx) ||
|
parseTEscNode(node, ctx) ||
|
||||||
@@ -227,7 +217,24 @@ function parseTNode(node: Element, ctx: ParsingContext): AST | null {
|
|||||||
if (node.tagName !== "t") {
|
if (node.tagName !== "t") {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return parseChildNodes(node, ctx);
|
const children: AST[] = [];
|
||||||
|
for (let child of node.childNodes) {
|
||||||
|
const ast = parseNode(child, ctx);
|
||||||
|
if (ast) {
|
||||||
|
children.push(ast);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (children.length) {
|
||||||
|
case 0:
|
||||||
|
return null;
|
||||||
|
case 1:
|
||||||
|
return children[0];
|
||||||
|
default:
|
||||||
|
return {
|
||||||
|
type: ASTType.Multi,
|
||||||
|
content: children,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -291,7 +298,7 @@ function parseDOMNode(node: Element, ctx: ParsingContext): AST | null {
|
|||||||
if (tagName === "t" && !dynamicTag) {
|
if (tagName === "t" && !dynamicTag) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ctx = Object.assign({}, ctx);
|
const children: AST[] = [];
|
||||||
if (tagName === "pre") {
|
if (tagName === "pre") {
|
||||||
ctx.inPreTag = true;
|
ctx.inPreTag = true;
|
||||||
}
|
}
|
||||||
@@ -301,7 +308,12 @@ function parseDOMNode(node: Element, ctx: ParsingContext): AST | null {
|
|||||||
const ref = node.getAttribute("t-ref");
|
const ref = node.getAttribute("t-ref");
|
||||||
node.removeAttribute("t-ref");
|
node.removeAttribute("t-ref");
|
||||||
|
|
||||||
const children = parseChildren(node, ctx);
|
for (let child of node.childNodes) {
|
||||||
|
const ast = parseNode(child, ctx);
|
||||||
|
if (ast) {
|
||||||
|
children.push(ast);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const nodeAttrsNames = node.getAttributeNames();
|
const nodeAttrsNames = node.getAttributeNames();
|
||||||
const attrs: ASTDomNode["attrs"] = {};
|
const attrs: ASTDomNode["attrs"] = {};
|
||||||
@@ -361,6 +373,9 @@ function parseDOMNode(node: Element, ctx: ParsingContext): AST | null {
|
|||||||
attrs[attr] = value;
|
attrs[attr] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (children.length === 1 && children[0].type === ASTType.TForEach) {
|
||||||
|
children[0].isOnlyChild = true;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
type: ASTType.DomNode,
|
type: ASTType.DomNode,
|
||||||
tag: tagName,
|
tag: tagName,
|
||||||
@@ -484,8 +499,9 @@ function parseTForEach(node: Element, ctx: ParsingContext): AST | null {
|
|||||||
elem,
|
elem,
|
||||||
body,
|
body,
|
||||||
memo,
|
memo,
|
||||||
deepRemove: needDeepRemove(body),
|
|
||||||
key,
|
key,
|
||||||
|
isOnlyChild: false,
|
||||||
|
hasNoComponent: hasNoComponent(body),
|
||||||
hasNoFirst,
|
hasNoFirst,
|
||||||
hasNoLast,
|
hasNoLast,
|
||||||
hasNoIndex,
|
hasNoIndex,
|
||||||
@@ -494,40 +510,54 @@ function parseTForEach(node: Element, ctx: ParsingContext): AST | null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns true if we are sure that a deep remove (without optimisation) is needed, for exemple
|
* @returns true if we are sure the ast does not contain any component
|
||||||
* if there is a portal.
|
|
||||||
*/
|
*/
|
||||||
function needDeepRemove(ast: AST): boolean {
|
function hasNoComponent(ast: AST): boolean {
|
||||||
switch (ast.type) {
|
switch (ast.type) {
|
||||||
case ASTType.Multi:
|
|
||||||
case ASTType.TForEach:
|
|
||||||
case ASTType.TIf:
|
|
||||||
return ast.deepRemove;
|
|
||||||
|
|
||||||
case ASTType.TPortal:
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case ASTType.TComponent:
|
case ASTType.TComponent:
|
||||||
case ASTType.TOut:
|
case ASTType.TOut:
|
||||||
case ASTType.TCall:
|
case ASTType.TCall:
|
||||||
case ASTType.TCallBlock:
|
case ASTType.TCallBlock:
|
||||||
case ASTType.TSlot:
|
case ASTType.TSlot:
|
||||||
|
return false;
|
||||||
|
case ASTType.TSet:
|
||||||
case ASTType.Text:
|
case ASTType.Text:
|
||||||
case ASTType.Comment:
|
case ASTType.Comment:
|
||||||
case ASTType.TEsc:
|
case ASTType.TEsc:
|
||||||
return false;
|
return true;
|
||||||
|
|
||||||
case ASTType.TKey:
|
case ASTType.TKey:
|
||||||
return needDeepRemove(ast.content);
|
return hasNoComponent(ast.content);
|
||||||
case ASTType.TDebug:
|
case ASTType.TDebug:
|
||||||
case ASTType.TLog:
|
case ASTType.TLog:
|
||||||
case ASTType.TTranslation:
|
case ASTType.TTranslation:
|
||||||
return ast.content ? needDeepRemove(ast.content) : false;
|
return ast.content ? hasNoComponent(ast.content) : true;
|
||||||
case ASTType.TSet:
|
case ASTType.TForEach:
|
||||||
return ast.body ? ast.body.some((ast) => needDeepRemove(ast)) : false;
|
return ast.hasNoComponent;
|
||||||
|
case ASTType.Multi:
|
||||||
case ASTType.DomNode:
|
case ASTType.DomNode: {
|
||||||
return ast.content.some((ast) => needDeepRemove(ast));
|
for (let elem of ast.content) {
|
||||||
|
if (!hasNoComponent(elem)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case ASTType.TIf: {
|
||||||
|
if (!hasNoComponent(ast.content)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (ast.tElif) {
|
||||||
|
for (let elem of ast.tElif) {
|
||||||
|
if (!hasNoComponent(elem.content)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ast.tElse && !hasNoComponent(ast.tElse)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,7 +599,13 @@ function parseTCall(node: Element, ctx: ParsingContext): AST | null {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const body = parseChildren(node, ctx);
|
const body: AST[] = [];
|
||||||
|
for (let child of node.childNodes) {
|
||||||
|
const ast = parseNode(child, ctx);
|
||||||
|
if (ast) {
|
||||||
|
body.push(ast);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: ASTType.TCall,
|
type: ASTType.TCall,
|
||||||
@@ -603,7 +639,10 @@ function parseTIf(node: Element, ctx: ParsingContext): AST | null {
|
|||||||
}
|
}
|
||||||
const condition = node.getAttribute("t-if")!;
|
const condition = node.getAttribute("t-if")!;
|
||||||
node.removeAttribute("t-if");
|
node.removeAttribute("t-if");
|
||||||
const content = parseNode(node, ctx) || { type: ASTType.Text, value: "" };
|
const content = parseNode(node, ctx);
|
||||||
|
if (!content) {
|
||||||
|
throw new Error("hmmm");
|
||||||
|
}
|
||||||
|
|
||||||
let nextElement = node.nextElementSibling;
|
let nextElement = node.nextElementSibling;
|
||||||
// t-elifs
|
// t-elifs
|
||||||
@@ -628,21 +667,12 @@ function parseTIf(node: Element, ctx: ParsingContext): AST | null {
|
|||||||
nextElement.remove();
|
nextElement.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
let deepRemove = needDeepRemove(content);
|
|
||||||
if (tElifs) {
|
|
||||||
deepRemove = deepRemove || tElifs.some((ast) => needDeepRemove(ast));
|
|
||||||
}
|
|
||||||
if (tElse) {
|
|
||||||
deepRemove = deepRemove || needDeepRemove(tElse);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: ASTType.TIf,
|
type: ASTType.TIf,
|
||||||
condition,
|
condition,
|
||||||
content,
|
content,
|
||||||
tElif: tElifs.length ? tElifs : null,
|
tElif: tElifs.length ? tElifs : null,
|
||||||
tElse,
|
tElse,
|
||||||
deepRemove,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -659,7 +689,13 @@ function parseTSetNode(node: Element, ctx: ParsingContext): AST | null {
|
|||||||
const defaultValue = node.innerHTML === node.textContent ? node.textContent || null : null;
|
const defaultValue = node.innerHTML === node.textContent ? node.textContent || null : null;
|
||||||
let body: AST[] | null = null;
|
let body: AST[] | null = null;
|
||||||
if (node.textContent !== node.innerHTML) {
|
if (node.textContent !== node.innerHTML) {
|
||||||
body = parseChildren(node, ctx);
|
body = [];
|
||||||
|
for (let child of node.childNodes) {
|
||||||
|
let childAst = parseNode(child, ctx);
|
||||||
|
if (childAst) {
|
||||||
|
body.push(childAst);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return { type: ASTType.TSet, name, value, defaultValue, body };
|
return { type: ASTType.TSet, name, value, defaultValue, body };
|
||||||
}
|
}
|
||||||
@@ -806,74 +842,25 @@ function parseTTranslation(node: Element, ctx: ParsingContext): AST | null {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Portal
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
function parseTPortal(node: Element, ctx: ParsingContext): AST | null {
|
|
||||||
if (!node.hasAttribute("t-portal")) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (node.tagName !== "t") {
|
|
||||||
throw new Error(
|
|
||||||
`Directive 't-portal' can only be used on <t> nodes (used on a <${node.tagName}>)`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
const target = node.getAttribute("t-portal")!;
|
|
||||||
node.removeAttribute("t-portal");
|
|
||||||
const content = parseNode(node, ctx);
|
|
||||||
if (!content) {
|
|
||||||
return {
|
|
||||||
type: ASTType.Text,
|
|
||||||
value: "",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
type: ASTType.TPortal,
|
|
||||||
target,
|
|
||||||
content,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// helpers
|
// helpers
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
function parseChildNodes(node: Element, ctx: ParsingContext): AST | null {
|
||||||
* Parse all the child nodes of a given node and return a list of ast elements
|
|
||||||
*/
|
|
||||||
function parseChildren(node: Node, ctx: ParsingContext): AST[] {
|
|
||||||
const children: AST[] = [];
|
const children: AST[] = [];
|
||||||
for (let child of node.childNodes) {
|
for (let child of node.childNodes) {
|
||||||
const childAst = parseNode(child, ctx);
|
const childAst = parseNode(child, ctx);
|
||||||
if (childAst) {
|
if (childAst) {
|
||||||
if (childAst.type === ASTType.Multi) {
|
children.push(childAst);
|
||||||
children.push(...childAst.content);
|
|
||||||
} else {
|
|
||||||
children.push(childAst);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return children;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse all the child nodes of a given node and return an ast if possible.
|
|
||||||
* In the case there are multiple children, they are wrapped in a astmulti.
|
|
||||||
*/
|
|
||||||
function parseChildNodes(node: Node, ctx: ParsingContext): AST | null {
|
|
||||||
const children = parseChildren(node, ctx);
|
|
||||||
switch (children.length) {
|
switch (children.length) {
|
||||||
case 0:
|
case 0:
|
||||||
return null;
|
return null;
|
||||||
case 1:
|
case 1:
|
||||||
return children[0];
|
return children[0];
|
||||||
default:
|
default:
|
||||||
return {
|
return { type: ASTType.Multi, content: children };
|
||||||
type: ASTType.Multi,
|
|
||||||
content: children,
|
|
||||||
deepRemove: children.some((ast) => needDeepRemove(ast)),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import type { ComponentNode } from "./component_node";
|
|||||||
|
|
||||||
export class Component {
|
export class Component {
|
||||||
static template: string = "";
|
static template: string = "";
|
||||||
|
static style: string = "";
|
||||||
static props?: any;
|
static props?: any;
|
||||||
|
|
||||||
props: any;
|
props: any;
|
||||||
@@ -18,10 +19,14 @@ export class Component {
|
|||||||
this.env = env;
|
this.env = env;
|
||||||
this.__owl__ = node;
|
this.__owl__ = node;
|
||||||
}
|
}
|
||||||
|
get el(): HTMLElement | Text | undefined {
|
||||||
|
const node = this.__owl__;
|
||||||
|
return node.bdom ? (node.bdom.firstNode() as any) : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
setup() {}
|
setup() {}
|
||||||
|
|
||||||
render() {
|
render(): Promise<void> {
|
||||||
this.__owl__.render();
|
return this.__owl__.render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,20 +8,12 @@ import {
|
|||||||
MountFiber,
|
MountFiber,
|
||||||
MountOptions,
|
MountOptions,
|
||||||
RootFiber,
|
RootFiber,
|
||||||
|
__internal__destroyed,
|
||||||
} from "./fibers";
|
} from "./fibers";
|
||||||
import { handleError, fibersInError } from "./error_handling";
|
import { handleError, fibersInError } from "./error_handling";
|
||||||
import { applyDefaultProps } from "./props_validation";
|
import { applyDefaultProps } from "./props_validation";
|
||||||
import { STATUS } from "./status";
|
import { STATUS } from "./status";
|
||||||
|
import { applyStyles } from "./style";
|
||||||
let currentNode: ComponentNode | null = null;
|
|
||||||
|
|
||||||
export function getCurrent(): ComponentNode | null {
|
|
||||||
return currentNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useComponent(): Component {
|
|
||||||
return currentNode!.component;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function component(
|
export function component(
|
||||||
name: string | typeof Component,
|
name: string | typeof Component,
|
||||||
@@ -72,6 +64,12 @@ export function component(
|
|||||||
// Component VNode
|
// Component VNode
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
let currentNode: ComponentNode | null = null;
|
||||||
|
|
||||||
|
export function getCurrent(): ComponentNode | null {
|
||||||
|
return currentNode;
|
||||||
|
}
|
||||||
|
|
||||||
type LifecycleHook = Function;
|
type LifecycleHook = Function;
|
||||||
|
|
||||||
export class ComponentNode<T extends typeof Component = typeof Component>
|
export class ComponentNode<T extends typeof Component = typeof Component>
|
||||||
@@ -97,7 +95,7 @@ export class ComponentNode<T extends typeof Component = typeof Component>
|
|||||||
mounted: LifecycleHook[] = [];
|
mounted: LifecycleHook[] = [];
|
||||||
willPatch: LifecycleHook[] = [];
|
willPatch: LifecycleHook[] = [];
|
||||||
patched: LifecycleHook[] = [];
|
patched: LifecycleHook[] = [];
|
||||||
willDestroy: LifecycleHook[] = [];
|
destroyed: LifecycleHook[] = [];
|
||||||
|
|
||||||
constructor(C: T, props: any, app: App, parent?: ComponentNode) {
|
constructor(C: T, props: any, app: App, parent?: ComponentNode) {
|
||||||
currentNode = this;
|
currentNode = this;
|
||||||
@@ -109,13 +107,17 @@ export class ComponentNode<T extends typeof Component = typeof Component>
|
|||||||
this.childEnv = env;
|
this.childEnv = env;
|
||||||
this.component = new C(props, env, this) as any;
|
this.component = new C(props, env, this) as any;
|
||||||
this.renderFn = app.getTemplate(C.template).bind(this.component, this.component, this);
|
this.renderFn = app.getTemplate(C.template).bind(this.component, this.component, this);
|
||||||
|
if (C.style) {
|
||||||
|
applyStyles(C);
|
||||||
|
}
|
||||||
this.component.setup();
|
this.component.setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
mountComponent(target: any, options?: MountOptions) {
|
mountComponent(target: any, options?: MountOptions): Promise<InstanceType<T>> {
|
||||||
const fiber = new MountFiber(this, target, options);
|
const fiber = new MountFiber(this, target, options);
|
||||||
this.app.scheduler.addFiber(fiber);
|
this.app.scheduler.addFiber(fiber);
|
||||||
this.initiateRender(fiber);
|
this.initiateRender(fiber);
|
||||||
|
return fiber.promise.then(() => this.component);
|
||||||
}
|
}
|
||||||
|
|
||||||
async initiateRender(fiber: Fiber | MountFiber) {
|
async initiateRender(fiber: Fiber | MountFiber) {
|
||||||
@@ -136,19 +138,14 @@ export class ComponentNode<T extends typeof Component = typeof Component>
|
|||||||
}
|
}
|
||||||
|
|
||||||
async render() {
|
async render() {
|
||||||
let current = this.fiber;
|
const current = this.fiber;
|
||||||
if (current && current.root.locked) {
|
|
||||||
await Promise.resolve();
|
|
||||||
// situation may have changed after the microtask tick
|
|
||||||
current = this.fiber;
|
|
||||||
}
|
|
||||||
if (current && !current.bdom && !fibersInError.has(current)) {
|
if (current && !current.bdom && !fibersInError.has(current)) {
|
||||||
return;
|
return current.root.promise;
|
||||||
}
|
}
|
||||||
if (!this.bdom && !current) {
|
if (!this.bdom && !current) {
|
||||||
|
// should find a way to return the future mounting promise
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fiber = makeRootFiber(this);
|
const fiber = makeRootFiber(this);
|
||||||
this.fiber = fiber;
|
this.fiber = fiber;
|
||||||
this.app.scheduler.addFiber(fiber);
|
this.app.scheduler.addFiber(fiber);
|
||||||
@@ -170,6 +167,7 @@ export class ComponentNode<T extends typeof Component = typeof Component>
|
|||||||
if (this.fiber && (current || !fiber.parent)) {
|
if (this.fiber && (current || !fiber.parent)) {
|
||||||
this._render(fiber);
|
this._render(fiber);
|
||||||
}
|
}
|
||||||
|
return fiber.root.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
_render(fiber: Fiber | RootFiber) {
|
_render(fiber: Fiber | RootFiber) {
|
||||||
@@ -182,33 +180,46 @@ export class ComponentNode<T extends typeof Component = typeof Component>
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
let shouldRemove = this.status === STATUS.MOUNTED;
|
if (this.status === STATUS.MOUNTED) {
|
||||||
this._destroy();
|
callWillUnmount(this);
|
||||||
if (shouldRemove) {
|
|
||||||
this.bdom!.remove();
|
this.bdom!.remove();
|
||||||
}
|
}
|
||||||
}
|
callDestroyed(this);
|
||||||
|
|
||||||
_destroy() {
|
function callWillUnmount(node: ComponentNode) {
|
||||||
const component = this.component;
|
const component = node.component;
|
||||||
if (this.status === STATUS.MOUNTED) {
|
for (let cb of node.willUnmount) {
|
||||||
for (let cb of this.willUnmount) {
|
cb.call(component);
|
||||||
|
}
|
||||||
|
for (let child of Object.values(node.children)) {
|
||||||
|
if (child.status === STATUS.MOUNTED) {
|
||||||
|
callWillUnmount(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function callDestroyed(node: ComponentNode) {
|
||||||
|
const component = node.component;
|
||||||
|
node.status = STATUS.DESTROYED;
|
||||||
|
for (let child of Object.values(node.children)) {
|
||||||
|
callDestroyed(child);
|
||||||
|
}
|
||||||
|
for (let cb of node.destroyed) {
|
||||||
cb.call(component);
|
cb.call(component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (let child of Object.values(this.children)) {
|
|
||||||
child._destroy();
|
|
||||||
}
|
|
||||||
for (let cb of this.willDestroy) {
|
|
||||||
cb.call(component);
|
|
||||||
}
|
|
||||||
this.status = STATUS.DESTROYED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateAndRender(props: any, parentFiber: Fiber) {
|
async updateAndRender(props: any, parentFiber: Fiber) {
|
||||||
// update
|
// update
|
||||||
const fiber = makeChildFiber(this, parentFiber);
|
const fiber = makeChildFiber(this, parentFiber);
|
||||||
this.fiber = fiber;
|
this.fiber = fiber;
|
||||||
|
if (this.willPatch.length) {
|
||||||
|
parentFiber.root.willPatch.push(fiber);
|
||||||
|
}
|
||||||
|
if (this.patched.length) {
|
||||||
|
parentFiber.root.patched.push(fiber);
|
||||||
|
}
|
||||||
const component = this.component;
|
const component = this.component;
|
||||||
applyDefaultProps(props, component.constructor as any);
|
applyDefaultProps(props, component.constructor as any);
|
||||||
const prom = Promise.all(this.willUpdateProps.map((f) => f.call(component, props)));
|
const prom = Promise.all(this.willUpdateProps.map((f) => f.call(component, props)));
|
||||||
@@ -216,40 +227,8 @@ export class ComponentNode<T extends typeof Component = typeof Component>
|
|||||||
if (fiber !== this.fiber) {
|
if (fiber !== this.fiber) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
component.props = props;
|
this.component.props = props;
|
||||||
this._render(fiber);
|
this._render(fiber);
|
||||||
const parentRoot = parentFiber.root;
|
|
||||||
if (this.willPatch.length) {
|
|
||||||
parentRoot.willPatch.push(fiber);
|
|
||||||
}
|
|
||||||
if (this.patched.length) {
|
|
||||||
parentRoot.patched.push(fiber);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds a child that has dom that is not yet updated, and update it. This
|
|
||||||
* method is meant to be used only in the context of repatching the dom after
|
|
||||||
* a mounted hook failed and was handled.
|
|
||||||
*/
|
|
||||||
updateDom() {
|
|
||||||
if (!this.fiber) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.bdom === this.fiber!.bdom) {
|
|
||||||
// If the error was handled by some child component, we need to find it to
|
|
||||||
// apply its change
|
|
||||||
for (let k in this.children) {
|
|
||||||
const child = this.children[k];
|
|
||||||
child.updateDom();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// if we get here, this is the component that handled the error and rerendered
|
|
||||||
// itself, so we can simply patch the dom
|
|
||||||
this.bdom!.patch(this.fiber!.bdom, false);
|
|
||||||
this.fiber!.appliedToDom = true;
|
|
||||||
this.fiber = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -276,35 +255,31 @@ export class ComponentNode<T extends typeof Component = typeof Component>
|
|||||||
|
|
||||||
patch() {
|
patch() {
|
||||||
this.bdom!.patch(this!.fiber!.bdom!, false);
|
this.bdom!.patch(this!.fiber!.bdom!, false);
|
||||||
this.cleanOutdatedChildren();
|
|
||||||
this.fiber!.appliedToDom = true;
|
this.fiber!.appliedToDom = true;
|
||||||
this.fiber = null;
|
this.fiber = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeRemove() {
|
beforeRemove() {
|
||||||
console.log('ddddddd')
|
visitRemovedNodes(this);
|
||||||
this._destroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
remove() {
|
remove() {
|
||||||
console.log('coucou')
|
|
||||||
this.bdom!.remove();
|
this.bdom!.remove();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cleanOutdatedChildren() {
|
function visitRemovedNodes(node: ComponentNode) {
|
||||||
const childrenEntries = Object.entries(this.children);
|
if (node.status === STATUS.MOUNTED) {
|
||||||
if (!childrenEntries.length) {
|
const component = node.component;
|
||||||
return;
|
for (let cb of node.willUnmount) {
|
||||||
}
|
cb.call(component);
|
||||||
const children = this.children;
|
|
||||||
for (const [key, node] of childrenEntries) {
|
|
||||||
const status = node.status;
|
|
||||||
if (status !== STATUS.MOUNTED) {
|
|
||||||
delete children[key];
|
|
||||||
if (status !== STATUS.DESTROYED) {
|
|
||||||
node.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (let child of Object.values(node.children)) {
|
||||||
|
visitRemovedNodes(child);
|
||||||
|
}
|
||||||
|
node.status = STATUS.DESTROYED;
|
||||||
|
if (node.destroyed.length) {
|
||||||
|
__internal__destroyed.push(node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,26 +16,27 @@ function _handleError(node: ComponentNode | null, error: any, isFirstRound = fal
|
|||||||
|
|
||||||
const errorHandlers = nodeErrorHandlers.get(node);
|
const errorHandlers = nodeErrorHandlers.get(node);
|
||||||
if (errorHandlers) {
|
if (errorHandlers) {
|
||||||
let stopped = false;
|
if (isFirstRound && fiber) {
|
||||||
// execute in the opposite order
|
fiber.root.counter--;
|
||||||
for (let i = errorHandlers.length - 1; i >= 0; i--) {
|
}
|
||||||
|
|
||||||
|
let propagate = true;
|
||||||
|
for (const h of errorHandlers) {
|
||||||
try {
|
try {
|
||||||
errorHandlers[i](error);
|
h(error);
|
||||||
stopped = true;
|
propagate = false;
|
||||||
break;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e;
|
error = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stopped) {
|
if (propagate) {
|
||||||
if (isFirstRound && fiber) {
|
return _handleError(node.parent, error);
|
||||||
fiber.root.counter--;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return _handleError(node.parent, error);
|
||||||
}
|
}
|
||||||
return _handleError(node.parent, error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ErrorParams = { error: any } & ({ node: ComponentNode } | { fiber: Fiber });
|
type ErrorParams = { error: any } & ({ node: ComponentNode } | { fiber: Fiber });
|
||||||
@@ -44,23 +45,13 @@ export function handleError(params: ErrorParams) {
|
|||||||
const node = "node" in params ? params.node : params.fiber.node;
|
const node = "node" in params ? params.node : params.fiber.node;
|
||||||
const fiber = "fiber" in params ? params.fiber : node.fiber!;
|
const fiber = "fiber" in params ? params.fiber : node.fiber!;
|
||||||
|
|
||||||
// resets the fibers on components if possible. This is important so that
|
|
||||||
// new renderings can be properly included in the initial one, if any.
|
|
||||||
let current: Fiber | null = fiber;
|
|
||||||
do {
|
|
||||||
current.node.fiber = current;
|
|
||||||
current = current.parent;
|
|
||||||
} while (current);
|
|
||||||
|
|
||||||
fibersInError.set(fiber.root, error);
|
fibersInError.set(fiber.root, error);
|
||||||
|
|
||||||
const handled = _handleError(node, error, true);
|
const handled = _handleError(node, error, true);
|
||||||
if (!handled) {
|
if (!handled) {
|
||||||
console.warn(`[Owl] Unhandled error. Destroying the root component`);
|
|
||||||
try {
|
try {
|
||||||
node.app.destroy();
|
node.app.destroy();
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return handled;
|
||||||
}
|
}
|
||||||
|
|||||||
+42
-65
@@ -1,46 +1,18 @@
|
|||||||
import { BDom, mount } from "../blockdom";
|
import type { BDom } from "../blockdom";
|
||||||
|
import { mount } from "../blockdom";
|
||||||
import type { ComponentNode } from "./component_node";
|
import type { ComponentNode } from "./component_node";
|
||||||
import { fibersInError, handleError } from "./error_handling";
|
|
||||||
import { STATUS } from "./status";
|
import { STATUS } from "./status";
|
||||||
|
import { fibersInError, handleError } from "./error_handling";
|
||||||
/**
|
|
||||||
* Cleans on the root fiber the patch and willPatch fiber lists
|
|
||||||
* It is typically needed when the same root fiber needs to recycle on
|
|
||||||
* of its children or grandchildren's fiber.
|
|
||||||
*/
|
|
||||||
function cleanPatchableFiber(child: Fiber, root: RootFiber) {
|
|
||||||
const { willPatch, patched } = root;
|
|
||||||
let i = willPatch.indexOf(child);
|
|
||||||
if (i > -1) {
|
|
||||||
willPatch.splice(i, 1);
|
|
||||||
}
|
|
||||||
i = patched.indexOf(child);
|
|
||||||
if (i > -1) {
|
|
||||||
patched.splice(i, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function makeChildFiber(node: ComponentNode, parent: Fiber): Fiber {
|
export function makeChildFiber(node: ComponentNode, parent: Fiber): Fiber {
|
||||||
let current = node.fiber;
|
let current = node.fiber;
|
||||||
if (current) {
|
if (current) {
|
||||||
// current is necessarily a rootfiber here
|
// current is necessarily a rootfiber here
|
||||||
let root = parent.root;
|
let root = parent.root;
|
||||||
const isSameRoot = current.root === root;
|
|
||||||
cancelFibers(root, current.children);
|
cancelFibers(root, current.children);
|
||||||
current.children = [];
|
current.children = [];
|
||||||
current.parent = parent;
|
current.parent = parent;
|
||||||
// only increment our rendering if we were not
|
root.counter++;
|
||||||
// already accounted for, or that we have been rendered
|
|
||||||
// already (in which case our fiber was removed from the root rendering)
|
|
||||||
if (!isSameRoot || current.bdom) {
|
|
||||||
root.counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isSameRoot) {
|
|
||||||
cleanPatchableFiber(current, root);
|
|
||||||
}
|
|
||||||
|
|
||||||
current.bdom = null;
|
|
||||||
current.root = root;
|
current.root = root;
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
@@ -58,11 +30,10 @@ export function makeRootFiber(node: ComponentNode): Fiber {
|
|||||||
if (fibersInError.has(current)) {
|
if (fibersInError.has(current)) {
|
||||||
fibersInError.delete(current);
|
fibersInError.delete(current);
|
||||||
fibersInError.delete(root);
|
fibersInError.delete(root);
|
||||||
current.appliedToDom = false;
|
|
||||||
}
|
}
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
const fiber = new RootFiber(node, null);
|
const fiber = new RootFiber(node);
|
||||||
if (node.willPatch.length) {
|
if (node.willPatch.length) {
|
||||||
fiber.willPatch.push(fiber);
|
fiber.willPatch.push(fiber);
|
||||||
}
|
}
|
||||||
@@ -113,18 +84,27 @@ export class Fiber {
|
|||||||
|
|
||||||
export class RootFiber extends Fiber {
|
export class RootFiber extends Fiber {
|
||||||
counter: number = 1;
|
counter: number = 1;
|
||||||
|
resolve: any;
|
||||||
|
promise: Promise<any>;
|
||||||
|
reject: any;
|
||||||
|
|
||||||
// only add stuff in this if they have registered some hooks
|
// only add stuff in this if they have registered some hooks
|
||||||
willPatch: Fiber[] = [];
|
willPatch: Fiber[] = [];
|
||||||
patched: Fiber[] = [];
|
patched: Fiber[] = [];
|
||||||
mounted: Fiber[] = [];
|
mounted: Fiber[] = [];
|
||||||
// A fiber is typically locked when it is completing and the patch has not, or is being applied.
|
|
||||||
// i.e.: render triggered in onWillUnmount or in willPatch will be delayed
|
constructor(node: ComponentNode) {
|
||||||
locked: boolean = false;
|
super(node, null);
|
||||||
|
this.counter = 1;
|
||||||
|
|
||||||
|
this.promise = new Promise((resolve, reject) => {
|
||||||
|
this.resolve = resolve;
|
||||||
|
this.reject = reject;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
complete() {
|
complete() {
|
||||||
const node = this.node;
|
const node = this.node;
|
||||||
this.locked = true;
|
|
||||||
let current: Fiber | undefined = undefined;
|
let current: Fiber | undefined = undefined;
|
||||||
try {
|
try {
|
||||||
// Step 1: calling all willPatch lifecycle hooks
|
// Step 1: calling all willPatch lifecycle hooks
|
||||||
@@ -144,13 +124,15 @@ export class RootFiber extends Fiber {
|
|||||||
|
|
||||||
// Step 2: patching the dom
|
// Step 2: patching the dom
|
||||||
node.bdom!.patch(this.bdom!, Object.keys(node.children).length > 0);
|
node.bdom!.patch(this.bdom!, Object.keys(node.children).length > 0);
|
||||||
node.cleanOutdatedChildren();
|
|
||||||
this.appliedToDom = true;
|
this.appliedToDom = true;
|
||||||
|
|
||||||
this.locked = false;
|
// Step 3: calling all destroyed hooks
|
||||||
// unregistering the fiber before mounted since it can do another render
|
for (let node of __internal__destroyed) {
|
||||||
// and that the current rendering is obviously completed
|
for (let cb of node.destroyed) {
|
||||||
node.fiber = null;
|
cb();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__internal__destroyed.length = 0;
|
||||||
|
|
||||||
// Step 4: calling all mounted lifecycle hooks
|
// Step 4: calling all mounted lifecycle hooks
|
||||||
let mountedFibers = this.mounted;
|
let mountedFibers = this.mounted;
|
||||||
@@ -173,13 +155,18 @@ export class RootFiber extends Fiber {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// unregistering the fiber
|
||||||
|
node.fiber = null;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.locked = false;
|
if (!handleError({ fiber: current || this, error: e })) {
|
||||||
handleError({ fiber: current || this, error: e });
|
this.reject(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export let __internal__destroyed: ComponentNode[] = [];
|
||||||
|
|
||||||
type Position = "first-child" | "last-child";
|
type Position = "first-child" | "last-child";
|
||||||
|
|
||||||
export interface MountOptions {
|
export interface MountOptions {
|
||||||
@@ -191,7 +178,7 @@ export class MountFiber extends RootFiber {
|
|||||||
position: Position;
|
position: Position;
|
||||||
|
|
||||||
constructor(node: ComponentNode, target: HTMLElement, options: MountOptions = {}) {
|
constructor(node: ComponentNode, target: HTMLElement, options: MountOptions = {}) {
|
||||||
super(node, null);
|
super(node);
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.position = options.position || "last-child";
|
this.position = options.position || "last-child";
|
||||||
}
|
}
|
||||||
@@ -199,26 +186,13 @@ export class MountFiber extends RootFiber {
|
|||||||
let current: Fiber | undefined = this;
|
let current: Fiber | undefined = this;
|
||||||
try {
|
try {
|
||||||
const node = this.node;
|
const node = this.node;
|
||||||
if (node.bdom) {
|
node.bdom = this.bdom;
|
||||||
// this is a complicated situation: if we mount a fiber with an existing
|
if (this.position === "last-child" || this.target.childNodes.length === 0) {
|
||||||
// bdom, this means that this same fiber was already completed, mounted,
|
mount(node.bdom!, this.target);
|
||||||
// but a crash occurred in some mounted hook. Then, it was handled and
|
|
||||||
// the new rendering is being applied.
|
|
||||||
node.updateDom();
|
|
||||||
} else {
|
} else {
|
||||||
node.bdom = this.bdom;
|
const firstChild = this.target.childNodes[0];
|
||||||
if (this.position === "last-child" || this.target.childNodes.length === 0) {
|
mount(node.bdom!, this.target, firstChild);
|
||||||
mount(node.bdom!, this.target);
|
|
||||||
} else {
|
|
||||||
const firstChild = this.target.childNodes[0];
|
|
||||||
mount(node.bdom!, this.target, firstChild);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// unregistering the fiber before mounted since it can do another render
|
|
||||||
// and that the current rendering is obviously completed
|
|
||||||
node.fiber = null;
|
|
||||||
|
|
||||||
node.status = STATUS.MOUNTED;
|
node.status = STATUS.MOUNTED;
|
||||||
this.appliedToDom = true;
|
this.appliedToDom = true;
|
||||||
let mountedFibers = this.mounted;
|
let mountedFibers = this.mounted;
|
||||||
@@ -229,8 +203,11 @@ export class MountFiber extends RootFiber {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
node.fiber = null;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
handleError({ fiber: current as Fiber, error: e });
|
if (!handleError({ fiber: current as Fiber, error: e })) {
|
||||||
|
this.reject(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ export function onWillUnmount(fn: () => Promise<void> | void | any) {
|
|||||||
node.willUnmount.unshift(fn);
|
node.willUnmount.unshift(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function onWillDestroy(fn: () => Promise<void> | void | any) {
|
export function onDestroyed(fn: () => Promise<void> | void | any) {
|
||||||
const node = getCurrent()!;
|
const node = getCurrent()!;
|
||||||
node.willDestroy.push(fn);
|
node.destroyed.push(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function onWillRender(fn: () => void | any) {
|
export function onWillRender(fn: () => void | any) {
|
||||||
@@ -59,13 +59,14 @@ export function onRendered(fn: () => void | any) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
type OnErrorCallback = (error: any) => void | any;
|
export function onError(fn: (error: Error) => void | any) {
|
||||||
export function onError(callback: OnErrorCallback) {
|
|
||||||
const node = getCurrent()!;
|
const node = getCurrent()!;
|
||||||
let handlers = nodeErrorHandlers.get(node);
|
let handlers = nodeErrorHandlers.get(node);
|
||||||
if (!handlers) {
|
if (handlers) {
|
||||||
|
handlers.push(fn);
|
||||||
|
} else {
|
||||||
handlers = [];
|
handlers = [];
|
||||||
|
handlers.push(fn);
|
||||||
nodeErrorHandlers.set(node, handlers);
|
nodeErrorHandlers.set(node, handlers);
|
||||||
}
|
}
|
||||||
handlers.push(callback);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,14 +19,6 @@ export function applyDefaultProps(props: { [key: string]: any }, ComponentClass:
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Prop validation helper
|
// Prop validation helper
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
function getPropDescription(staticProps: any) {
|
|
||||||
if (staticProps instanceof Array) {
|
|
||||||
return Object.fromEntries(
|
|
||||||
staticProps.map((p) => (p.endsWith("?") ? [p.slice(0, -1), false] : [p, true]))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return staticProps || { "*": true };
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate the component props (or next props) against the (static) props
|
* Validate the component props (or next props) against the (static) props
|
||||||
@@ -41,34 +33,46 @@ export const validateProps = function (name: string | typeof Component, props: a
|
|||||||
|
|
||||||
applyDefaultProps(props, ComponentClass);
|
applyDefaultProps(props, ComponentClass);
|
||||||
|
|
||||||
let propsDef = getPropDescription(ComponentClass.props);
|
const propsDef = ComponentClass.props;
|
||||||
const allowAdditionalProps = "*" in propsDef;
|
if (propsDef instanceof Array) {
|
||||||
|
// list of strings (prop names)
|
||||||
for (let propName in propsDef) {
|
for (const propName of propsDef) {
|
||||||
if (propName === "*") {
|
if (propName[propName.length - 1] === "?") {
|
||||||
continue;
|
// optional prop
|
||||||
}
|
break;
|
||||||
if (props[propName] === undefined) {
|
}
|
||||||
if (propsDef[propName] && !propsDef[propName].optional) {
|
if (!(propName in props)) {
|
||||||
throw new Error(`Missing props '${propName}' (component '${ComponentClass.name}')`);
|
throw new Error(`Missing props '${propName}' (component '${ComponentClass.name}')`);
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let isValid;
|
for (let key in props) {
|
||||||
try {
|
if (!propsDef.includes(key) && !propsDef.includes(key + "?")) {
|
||||||
isValid = isValidProp(props[propName], propsDef[propName]);
|
throw new Error(`Unknown prop '${key}' given to component '${ComponentClass.name}'`);
|
||||||
} catch (e) {
|
}
|
||||||
(e as Error).message = `Invalid prop '${propName}' in component ${ComponentClass.name} (${
|
|
||||||
(e as Error).message
|
|
||||||
})`;
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
if (!isValid) {
|
} else if (propsDef) {
|
||||||
throw new Error(`Invalid Prop '${propName}' in component '${ComponentClass.name}'`);
|
// propsDef is an object now
|
||||||
|
for (let propName in propsDef) {
|
||||||
|
if (props[propName] === undefined) {
|
||||||
|
if (propsDef[propName] && !propsDef[propName].optional) {
|
||||||
|
throw new Error(`Missing props '${propName}' (component '${ComponentClass.name}')`);
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let isValid;
|
||||||
|
try {
|
||||||
|
isValid = isValidProp(props[propName], propsDef[propName]);
|
||||||
|
} catch (e) {
|
||||||
|
(e as Error).message = `Invalid prop '${propName}' in component ${ComponentClass.name} (${
|
||||||
|
(e as Error).message
|
||||||
|
})`;
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
if (!isValid) {
|
||||||
|
throw new Error(`Invalid Prop '${propName}' in component '${ComponentClass.name}'`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!allowAdditionalProps) {
|
|
||||||
for (let propName in props) {
|
for (let propName in props) {
|
||||||
if (!(propName in propsDef)) {
|
if (!(propName in propsDef)) {
|
||||||
throw new Error(`Unknown prop '${propName}' given to component '${ComponentClass.name}'`);
|
throw new Error(`Unknown prop '${propName}' given to component '${ComponentClass.name}'`);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { fibersInError } from "./error_handling";
|
|
||||||
import { Fiber, RootFiber } from "./fibers";
|
import { Fiber, RootFiber } from "./fibers";
|
||||||
|
import { fibersInError } from "./error_handling";
|
||||||
import { STATUS } from "./status";
|
import { STATUS } from "./status";
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -38,12 +38,19 @@ export class Scheduler {
|
|||||||
flush() {
|
flush() {
|
||||||
this.tasks.forEach((fiber) => {
|
this.tasks.forEach((fiber) => {
|
||||||
if (fiber.root !== fiber) {
|
if (fiber.root !== fiber) {
|
||||||
|
// this is wrong! should be something like
|
||||||
|
// if (this.tasks.has(fiber.root)) {
|
||||||
|
// // parent rendering has completed
|
||||||
|
// fiber.resolve();
|
||||||
|
// this.tasks.delete(fiber);
|
||||||
|
// }
|
||||||
this.tasks.delete(fiber);
|
this.tasks.delete(fiber);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const hasError = fibersInError.has(fiber);
|
const hasError = fibersInError.has(fiber);
|
||||||
if (hasError && fiber.counter !== 0) {
|
if (hasError && fiber.counter !== 0) {
|
||||||
this.tasks.delete(fiber);
|
this.tasks.delete(fiber);
|
||||||
|
fiber.reject(fibersInError.get(fiber));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (fiber.node.status === STATUS.DESTROYED) {
|
if (fiber.node.status === STATUS.DESTROYED) {
|
||||||
@@ -54,6 +61,7 @@ export class Scheduler {
|
|||||||
if (fiber.counter === 0) {
|
if (fiber.counter === 0) {
|
||||||
if (!hasError) {
|
if (!hasError) {
|
||||||
fiber.complete();
|
fiber.complete();
|
||||||
|
fiber.resolve();
|
||||||
}
|
}
|
||||||
this.tasks.delete(fiber);
|
this.tasks.delete(fiber);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
import { Component } from "./component";
|
||||||
|
|
||||||
|
export const globalStylesheets: { [key: string]: HTMLStyleElement } = {};
|
||||||
|
|
||||||
|
export function registerSheet(id: string, css: string) {
|
||||||
|
const sheet = document.createElement("style");
|
||||||
|
sheet.innerHTML = processSheet(css);
|
||||||
|
globalStylesheets[id] = sheet;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply the stylesheets defined by the component. Note that we need to make
|
||||||
|
* sure all inherited stylesheets are applied as well, in a reverse order to
|
||||||
|
* ensure that <style/> will be applied to the DOM in the order they are
|
||||||
|
* included in the document. We then delete the `style` key from the constructor
|
||||||
|
* to make sure we do not apply it again.
|
||||||
|
*/
|
||||||
|
export function applyStyles(ComponentClass: typeof Component) {
|
||||||
|
const toApply: [string, string][] = [];
|
||||||
|
while (ComponentClass && ComponentClass.style) {
|
||||||
|
if (ComponentClass.hasOwnProperty("style")) {
|
||||||
|
toApply.push([ComponentClass.style, ComponentClass.name]);
|
||||||
|
delete (ComponentClass as any).style;
|
||||||
|
}
|
||||||
|
ComponentClass = Object.getPrototypeOf(ComponentClass);
|
||||||
|
}
|
||||||
|
while (toApply.length) {
|
||||||
|
const [styleId, componentName] = toApply.pop()!;
|
||||||
|
activateSheet(styleId, componentName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function activateSheet(id: string, name: string) {
|
||||||
|
const sheet = globalStylesheets[id];
|
||||||
|
if (!sheet) {
|
||||||
|
throw new Error(
|
||||||
|
`Invalid css stylesheet for component '${name}'. Did you forget to use the 'css' tag helper?`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
sheet.dataset.component = name;
|
||||||
|
document.head.appendChild(sheet);
|
||||||
|
}
|
||||||
|
|
||||||
|
function processSheet(str: string): string {
|
||||||
|
const tokens = str.split(/(\{|\}|;)/).map((s) => s.trim());
|
||||||
|
const selectorStack: string[][] = [];
|
||||||
|
const parts: string[] = [];
|
||||||
|
let rules: string[] = [];
|
||||||
|
function generateSelector(stackIndex: number, parentSelector?: string) {
|
||||||
|
const parts: string[] = [];
|
||||||
|
for (const selector of selectorStack[stackIndex]) {
|
||||||
|
let part = (parentSelector && parentSelector + " " + selector) || selector;
|
||||||
|
if (part.includes("&")) {
|
||||||
|
part = selector.replace(/&/g, parentSelector || "");
|
||||||
|
}
|
||||||
|
if (stackIndex < selectorStack.length - 1) {
|
||||||
|
part = generateSelector(stackIndex + 1, part);
|
||||||
|
}
|
||||||
|
parts.push(part);
|
||||||
|
}
|
||||||
|
return parts.join(", ");
|
||||||
|
}
|
||||||
|
function generateRules() {
|
||||||
|
if (rules.length) {
|
||||||
|
parts.push(generateSelector(0) + " {");
|
||||||
|
parts.push(...rules);
|
||||||
|
parts.push("}");
|
||||||
|
rules = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (tokens.length) {
|
||||||
|
let token = tokens.shift()!;
|
||||||
|
if (token === "}") {
|
||||||
|
generateRules();
|
||||||
|
selectorStack.pop();
|
||||||
|
} else {
|
||||||
|
if (tokens[0] === "{") {
|
||||||
|
generateRules();
|
||||||
|
selectorStack.push(token.split(/\s*,\s*/));
|
||||||
|
tokens.shift();
|
||||||
|
}
|
||||||
|
if (tokens[0] === ";") {
|
||||||
|
rules.push(" " + token + ";");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parts.join("\n");
|
||||||
|
}
|
||||||
+12
-10
@@ -1,6 +1,6 @@
|
|||||||
import type { Env } from "./app/app";
|
import type { Env } from "./app/app";
|
||||||
import { getCurrent } from "./component/component_node";
|
import { getCurrent } from "./component/component_node";
|
||||||
import { onMounted, onPatched, onWillUnmount } from "./component/lifecycle_hooks";
|
import { onMounted, onPatched, onWillPatch, onWillUnmount } from "./component/lifecycle_hooks";
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// useRef
|
// useRef
|
||||||
@@ -12,10 +12,9 @@ import { onMounted, onPatched, onWillUnmount } from "./component/lifecycle_hooks
|
|||||||
*/
|
*/
|
||||||
export function useRef<T extends HTMLElement = HTMLElement>(name: string): { el: T | null } {
|
export function useRef<T extends HTMLElement = HTMLElement>(name: string): { el: T | null } {
|
||||||
const node = getCurrent()!;
|
const node = getCurrent()!;
|
||||||
const refs = node.refs;
|
|
||||||
return {
|
return {
|
||||||
get el(): T | null {
|
get el(): T | null {
|
||||||
return refs[name] || null;
|
return node.refs[name] || null;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -39,9 +38,7 @@ export function useEnv<E extends Env>(): E {
|
|||||||
*/
|
*/
|
||||||
export function useSubEnv(envExtension: Env) {
|
export function useSubEnv(envExtension: Env) {
|
||||||
const node = getCurrent()!;
|
const node = getCurrent()!;
|
||||||
const env = Object.create(node.childEnv);
|
node.childEnv = Object.freeze(Object.assign({}, node.childEnv, envExtension));
|
||||||
const descrs = Object.getOwnPropertyDescriptors(envExtension);
|
|
||||||
node.childEnv = Object.freeze(Object.defineProperties(env, descrs));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -76,12 +73,17 @@ export function useEffect(effect: Effect, computeDependencies: () => any[] = ()
|
|||||||
cleanup = effect(...dependencies) || NO_OP;
|
cleanup = effect(...dependencies) || NO_OP;
|
||||||
});
|
});
|
||||||
|
|
||||||
onPatched(() => {
|
let shouldReapplyOnPatch = false;
|
||||||
|
onWillPatch(() => {
|
||||||
const newDeps = computeDependencies();
|
const newDeps = computeDependencies();
|
||||||
const shouldReapply = newDeps.some((val, i) => val !== dependencies[i]);
|
shouldReapplyOnPatch = newDeps.some((val, i) => val !== dependencies[i]);
|
||||||
if (shouldReapply) {
|
if (shouldReapplyOnPatch) {
|
||||||
dependencies = newDeps;
|
|
||||||
cleanup();
|
cleanup();
|
||||||
|
dependencies = newDeps;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
onPatched(() => {
|
||||||
|
if (shouldReapplyOnPatch) {
|
||||||
cleanup = effect(...dependencies) || NO_OP;
|
cleanup = effect(...dependencies) || NO_OP;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+25
-7
@@ -9,7 +9,6 @@ import {
|
|||||||
remove,
|
remove,
|
||||||
text,
|
text,
|
||||||
toggler,
|
toggler,
|
||||||
comment,
|
|
||||||
} from "./blockdom";
|
} from "./blockdom";
|
||||||
import { mainEventHandler } from "./component/handler";
|
import { mainEventHandler } from "./component/handler";
|
||||||
|
|
||||||
@@ -29,18 +28,37 @@ export const blockDom = {
|
|||||||
toggler,
|
toggler,
|
||||||
createBlock,
|
createBlock,
|
||||||
html,
|
html,
|
||||||
comment,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export { App, mount } from "./app/app";
|
import type { AppConfig } from "./app/app";
|
||||||
export { Component } from "./component/component";
|
import { App } from "./app/app";
|
||||||
export { useComponent } from "./component/component_node";
|
import { Component } from "./component/component";
|
||||||
|
import { getCurrent } from "./component/component_node";
|
||||||
|
|
||||||
|
export { App, Component };
|
||||||
|
|
||||||
|
export async function mount<T extends typeof Component>(
|
||||||
|
C: T,
|
||||||
|
target: HTMLElement,
|
||||||
|
config: AppConfig = {}
|
||||||
|
): Promise<InstanceType<T>> {
|
||||||
|
const app = new App(C);
|
||||||
|
return app.configure(config).mount(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useComponent(): Component {
|
||||||
|
const current = getCurrent();
|
||||||
|
return current!.component;
|
||||||
|
}
|
||||||
|
|
||||||
export { status } from "./component/status";
|
export { status } from "./component/status";
|
||||||
|
export { Portal } from "./portal";
|
||||||
export { Memo } from "./memo";
|
export { Memo } from "./memo";
|
||||||
export { xml } from "./app/template_set";
|
export { css, xml } from "./tags";
|
||||||
export { useState, reactive } from "./reactivity";
|
export { useState, reactive } from "./reactivity";
|
||||||
export { useEffect, useEnv, useExternalListener, useRef, useSubEnv } from "./hooks";
|
export { useEffect, useEnv, useExternalListener, useRef, useSubEnv } from "./hooks";
|
||||||
export { EventBus, whenReady, loadFile, markup } from "./utils";
|
export { EventBus, whenReady, loadFile, markup } from "./utils";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
onWillStart,
|
onWillStart,
|
||||||
onMounted,
|
onMounted,
|
||||||
@@ -50,7 +68,7 @@ export {
|
|||||||
onPatched,
|
onPatched,
|
||||||
onWillRender,
|
onWillRender,
|
||||||
onRendered,
|
onRendered,
|
||||||
onWillDestroy,
|
onDestroyed,
|
||||||
onError,
|
onError,
|
||||||
} from "./component/lifecycle_hooks";
|
} from "./component/lifecycle_hooks";
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
import { Component } from "./component/component";
|
import { Component } from "./component/component";
|
||||||
import type { ComponentNode } from "./component/component_node";
|
import type { ComponentNode } from "./component/component_node";
|
||||||
import { xml } from "./app/template_set";
|
import { xml } from "./tags";
|
||||||
import { Fiber } from "./component/fibers";
|
import { Fiber } from "./component/fibers";
|
||||||
|
|
||||||
export class Memo extends Component {
|
export class Memo extends Component {
|
||||||
|
|||||||
+23
-4
@@ -1,21 +1,22 @@
|
|||||||
|
import type { ComponentNode } from "./component/component_node";
|
||||||
|
import { Component } from "./component/component";
|
||||||
|
import { xml } from "./tags";
|
||||||
import { BDom, text, VNode } from "./blockdom";
|
import { BDom, text, VNode } from "./blockdom";
|
||||||
|
|
||||||
const VText: any = text("").constructor;
|
const VText: any = text("").constructor;
|
||||||
|
|
||||||
export class VPortal extends VText implements Partial<VNode<VPortal>> {
|
class VPortal extends VText implements Partial<VNode<VPortal>> {
|
||||||
// selector: string;
|
// selector: string;
|
||||||
realBDom: BDom | null;
|
realBDom: BDom | null;
|
||||||
target: HTMLElement | null = null;
|
target: HTMLElement | null = null;
|
||||||
|
|
||||||
constructor(selector: string, realBDom: BDom, ownerComponent: ComponentNode) {
|
constructor(selector: string, realBDom: BDom) {
|
||||||
super("");
|
super("");
|
||||||
this.ownerComponent = ownerComponent;
|
|
||||||
this.selector = selector;
|
this.selector = selector;
|
||||||
this.realBDom = realBDom;
|
this.realBDom = realBDom;
|
||||||
}
|
}
|
||||||
mount(parent: HTMLElement, anchor: ChildNode) {
|
mount(parent: HTMLElement, anchor: ChildNode) {
|
||||||
super.mount(parent, anchor);
|
super.mount(parent, anchor);
|
||||||
this.ownerComponent.willDestroy.push(() => this.cleanup());
|
|
||||||
this.target = document.querySelector(this.selector) as any;
|
this.target = document.querySelector(this.selector) as any;
|
||||||
if (!this.target) {
|
if (!this.target) {
|
||||||
let el: any = this.el;
|
let el: any = this.el;
|
||||||
@@ -49,3 +50,21 @@ export class VPortal extends VText implements Partial<VNode<VPortal>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class Portal extends Component {
|
||||||
|
static template = xml`<t t-slot="default"/>`;
|
||||||
|
static props = {
|
||||||
|
target: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
constructor(props: any, env: any, node: ComponentNode) {
|
||||||
|
super(props, env, node);
|
||||||
|
node._render = function (fiber: any) {
|
||||||
|
const bdom = new VPortal(props.target, this.renderFn());
|
||||||
|
fiber.bdom = bdom;
|
||||||
|
fiber.root.counter--;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+7
-8
@@ -49,10 +49,6 @@ function observeTargetKey(target: Target, key: ObjectKey, callback: Callback): v
|
|||||||
keyToCallbacks.set(key, new Set());
|
keyToCallbacks.set(key, new Set());
|
||||||
}
|
}
|
||||||
keyToCallbacks.get(key)!.add(callback);
|
keyToCallbacks.get(key)!.add(callback);
|
||||||
if (!callbacksToTargets.has(callback)) {
|
|
||||||
callbacksToTargets.set(callback, new Set());
|
|
||||||
}
|
|
||||||
callbacksToTargets.get(callback)!.add(target);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Notify Reactives that are observing a given target that a key has changed on
|
* Notify Reactives that are observing a given target that a key has changed on
|
||||||
@@ -99,10 +95,9 @@ function clearReactivesForCallback(callback: Callback): void {
|
|||||||
callbacks.delete(callback);
|
callbacks.delete(callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
targetsToClear.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const reactiveCache = new WeakMap<Target, WeakMap<Callback, Reactive>>();
|
const reactiveCache = new WeakMap<Target, Map<Callback, Reactive>>();
|
||||||
/**
|
/**
|
||||||
* Creates a reactive proxy for an object. Reading data on the reactive object
|
* Creates a reactive proxy for an object. Reading data on the reactive object
|
||||||
* subscribes to changes to the data. Writing data on the object will cause the
|
* subscribes to changes to the data. Writing data on the object will cause the
|
||||||
@@ -130,7 +125,7 @@ const reactiveCache = new WeakMap<Target, WeakMap<Callback, Reactive>>();
|
|||||||
* reactive has changed
|
* reactive has changed
|
||||||
* @returns a proxy that tracks changes to it
|
* @returns a proxy that tracks changes to it
|
||||||
*/
|
*/
|
||||||
export function reactive<T extends Target>(target: T, callback: Callback = () => {}): Reactive<T> {
|
export function reactive<T extends Target>(target: T, callback: Callback): Reactive<T> {
|
||||||
if (!canBeMadeReactive(target)) {
|
if (!canBeMadeReactive(target)) {
|
||||||
throw new Error(`Cannot make the given value reactive`);
|
throw new Error(`Cannot make the given value reactive`);
|
||||||
}
|
}
|
||||||
@@ -187,6 +182,10 @@ export function reactive<T extends Target>(target: T, callback: Callback = () =>
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
reactivesForTarget.set(callback, proxy);
|
reactivesForTarget.set(callback, proxy);
|
||||||
|
if (!callbacksToTargets.has(callback)) {
|
||||||
|
callbacksToTargets.set(callback, new Set());
|
||||||
|
}
|
||||||
|
callbacksToTargets.get(callback)!.add(target);
|
||||||
}
|
}
|
||||||
return reactivesForTarget.get(callback) as Reactive<T>;
|
return reactivesForTarget.get(callback) as Reactive<T>;
|
||||||
}
|
}
|
||||||
@@ -233,9 +232,9 @@ export function useState<T extends object>(state: T): Reactive<T> {
|
|||||||
node,
|
node,
|
||||||
batched(() => node.render())
|
batched(() => node.render())
|
||||||
);
|
);
|
||||||
onWillUnmount(() => clearReactivesForCallback(render));
|
|
||||||
}
|
}
|
||||||
const render = batchedRenderFunctions.get(node)!;
|
const render = batchedRenderFunctions.get(node)!;
|
||||||
const reactiveState = reactive(state, render);
|
const reactiveState = reactive(state, render);
|
||||||
|
onWillUnmount(() => clearReactivesForCallback(render));
|
||||||
return reactiveState;
|
return reactiveState;
|
||||||
}
|
}
|
||||||
|
|||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
import { registerSheet } from "./component/style";
|
||||||
|
import { globalTemplates } from "./app/template_set";
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Global templates
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export function xml(...args: Parameters<typeof String.raw>) {
|
||||||
|
const name = `__template__${xml.nextId++}`;
|
||||||
|
const value = String.raw(...args);
|
||||||
|
globalTemplates[name] = value;
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
xml.nextId = 1;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Global stylesheets
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export function css(strings: TemplateStringsArray, ...args: any[]) {
|
||||||
|
const name = `__sheet__${css.nextId++}`;
|
||||||
|
const value = String.raw(strings, ...args);
|
||||||
|
registerSheet(name, value);
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
css.nextId = 1;
|
||||||
@@ -49,16 +49,14 @@ exports[`Reactivity: useState concurrent renderings 3`] = `
|
|||||||
exports[`Reactivity: useState destroyed component before being mounted is inactive 1`] = `
|
exports[`Reactivity: useState destroyed component before being mounted is inactive 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2;
|
let d1 = ctx['contextObj'].a;
|
||||||
if (ctx['state'].flag) {
|
return block1([d1]);
|
||||||
b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
|
||||||
return block1([], [b2]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -66,21 +64,8 @@ exports[`Reactivity: useState destroyed component before being mounted is inacti
|
|||||||
exports[`Reactivity: useState destroyed component before being mounted is inactive 2`] = `
|
exports[`Reactivity: useState destroyed component before being mounted is inactive 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['contextObj'].a;
|
|
||||||
return block1([txt1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`Reactivity: useState destroyed component is inactive 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -94,16 +79,35 @@ exports[`Reactivity: useState destroyed component is inactive 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`Reactivity: useState destroyed component is inactive 2`] = `
|
exports[`Reactivity: useState destroyed component is inactive 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['contextObj'].a;
|
let d1 = ctx['contextObj'].a;
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Reactivity: useState destroyed component is inactive 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let b2;
|
||||||
|
if (ctx['state'].flag) {
|
||||||
|
b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
||||||
|
}
|
||||||
|
return block1([], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -111,14 +115,15 @@ exports[`Reactivity: useState destroyed component is inactive 2`] = `
|
|||||||
exports[`Reactivity: useState one components can subscribe twice to same context 1`] = `
|
exports[`Reactivity: useState one components can subscribe twice to same context 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['contextObj1'].a;
|
let d1 = ctx['contextObj1'].a;
|
||||||
let txt2 = ctx['contextObj2'].b;
|
let d2 = ctx['contextObj2'].b;
|
||||||
return block1([txt1, txt2]);
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -126,14 +131,14 @@ exports[`Reactivity: useState one components can subscribe twice to same context
|
|||||||
exports[`Reactivity: useState parent and children subscribed to same context 1`] = `
|
exports[`Reactivity: useState parent and children subscribed to same context 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`);
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
let d1 = ctx['contextObj'].a;
|
||||||
let txt1 = ctx['contextObj'].b;
|
return block1([d1]);
|
||||||
return block1([txt1], [b2]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -141,13 +146,15 @@ exports[`Reactivity: useState parent and children subscribed to same context 1`]
|
|||||||
exports[`Reactivity: useState parent and children subscribed to same context 2`] = `
|
exports[`Reactivity: useState parent and children subscribed to same context 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['contextObj'].a;
|
let b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
||||||
return block1([txt1]);
|
let d1 = ctx['contextObj'].b;
|
||||||
|
return block1([d1], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -218,14 +225,14 @@ exports[`Reactivity: useState several nodes on different level use same context
|
|||||||
exports[`Reactivity: useState two components are updated in parallel 1`] = `
|
exports[`Reactivity: useState two components are updated in parallel 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
let d1 = ctx['contextObj'].value;
|
||||||
let b3 = component(\`Child\`, {}, key + \`__2\`, node, ctx);
|
return block1([d1]);
|
||||||
return block1([], [b2, b3]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -233,21 +240,8 @@ exports[`Reactivity: useState two components are updated in parallel 1`] = `
|
|||||||
exports[`Reactivity: useState two components are updated in parallel 2`] = `
|
exports[`Reactivity: useState two components are updated in parallel 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['contextObj'].value;
|
|
||||||
return block1([txt1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`Reactivity: useState two components can subscribe to same context 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
||||||
|
|
||||||
@@ -259,16 +253,33 @@ exports[`Reactivity: useState two components can subscribe to same context 1`] =
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`Reactivity: useState two components can subscribe to same context 2`] = `
|
exports[`Reactivity: useState two components can subscribe to same context 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['contextObj'].value;
|
let d1 = ctx['contextObj'].value;
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Reactivity: useState two components can subscribe to same context 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
||||||
|
let b3 = component(\`Child\`, {}, key + \`__2\`, node, ctx);
|
||||||
|
return block1([], [b2, b3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -276,7 +287,38 @@ exports[`Reactivity: useState two components can subscribe to same context 2`] =
|
|||||||
exports[`Reactivity: useState two independent components on different levels are updated in parallel 1`] = `
|
exports[`Reactivity: useState two independent components on different levels are updated in parallel 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['contextObj'].value;
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Reactivity: useState two independent components on different levels are updated in parallel 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
||||||
|
return block1([], [b2]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Reactivity: useState two independent components on different levels are updated in parallel 3`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
||||||
|
|
||||||
@@ -288,44 +330,17 @@ exports[`Reactivity: useState two independent components on different levels are
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`Reactivity: useState two independent components on different levels are updated in parallel 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['contextObj'].value;
|
|
||||||
return block1([txt1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`Reactivity: useState two independent components on different levels are updated in parallel 3`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
|
||||||
return block1([], [b2]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`Reactivity: useState useContext=useState hook is reactive, for one component 1`] = `
|
exports[`Reactivity: useState useContext=useState hook is reactive, for one component 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['contextObj'].value;
|
let d1 = ctx['contextObj'].value;
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -333,8 +348,23 @@ exports[`Reactivity: useState useContext=useState hook is reactive, for one comp
|
|||||||
exports[`Reactivity: useState useless atoms should be deleted 1`] = `
|
exports[`Reactivity: useState useless atoms should be deleted 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['state'].quantity;
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Reactivity: useState useless atoms should be deleted 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/> Total: <block-text-0/> Count: <block-text-1/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/> Total: <block-text-0/> Count: <block-text-1/></div>\`);
|
||||||
|
|
||||||
@@ -348,23 +378,9 @@ exports[`Reactivity: useState useless atoms should be deleted 1`] = `
|
|||||||
}
|
}
|
||||||
ctx = ctx.__proto__;
|
ctx = ctx.__proto__;
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
let txt1 = ctx['total'];
|
let d1 = ctx['total'];
|
||||||
let txt2 = Object.keys(ctx['state']).length;
|
let d2 = Object.keys(ctx['state']).length;
|
||||||
return block1([txt1, txt2], [b2]);
|
return block1([d1, d2], [b2]);
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`Reactivity: useState useless atoms should be deleted 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['state'].quantity;
|
|
||||||
return block1([txt1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -372,13 +388,14 @@ exports[`Reactivity: useState useless atoms should be deleted 2`] = `
|
|||||||
exports[`Reactivity: useState very simple use, with initial value 1`] = `
|
exports[`Reactivity: useState very simple use, with initial value 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['contextObj'].value;
|
let d1 = ctx['contextObj'].value;
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
||||||
|
|
||||||
exports[`app App supports env with getters/setters 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/> <block-text-1/></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['env'].someVal;
|
|
||||||
let txt2 = Object.keys(ctx['env'].services);
|
|
||||||
return block1([txt1, txt2]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`app can configure an app with props 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['props'].value;
|
|
||||||
return block1([txt1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`app destroy remove the widget from the DOM 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return block1();
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
import { App, Component, xml } from "../../src";
|
|
||||||
import { status } from "../../src/component/status";
|
|
||||||
import { makeTestFixture, snapshotEverything, nextTick, elem } from "../helpers";
|
|
||||||
|
|
||||||
let fixture: HTMLElement;
|
|
||||||
|
|
||||||
snapshotEverything();
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = makeTestFixture();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("app", () => {
|
|
||||||
test("destroy remove the widget from the DOM", async () => {
|
|
||||||
class SomeComponent extends Component {
|
|
||||||
static template = xml`<div/>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const app = new App(SomeComponent);
|
|
||||||
const comp = await app.mount(fixture);
|
|
||||||
const el = elem(comp);
|
|
||||||
expect(document.contains(el)).toBe(true);
|
|
||||||
app.destroy();
|
|
||||||
expect(document.contains(el)).toBe(false);
|
|
||||||
expect(status(comp)).toBe("destroyed");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("App supports env with getters/setters", async () => {
|
|
||||||
let someVal = "maggot";
|
|
||||||
|
|
||||||
const services: any = { serv1: "" };
|
|
||||||
const env = {
|
|
||||||
get someVal() {
|
|
||||||
return someVal;
|
|
||||||
},
|
|
||||||
services,
|
|
||||||
};
|
|
||||||
|
|
||||||
class SomeComponent extends Component {
|
|
||||||
static template = xml`<div><t t-esc="env.someVal" /> <t t-esc="Object.keys(env.services)" /></div>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const app = new App(SomeComponent, { env });
|
|
||||||
const comp = await app.mount(fixture);
|
|
||||||
expect(fixture.innerHTML).toBe("<div>maggot serv1</div>");
|
|
||||||
someVal = "brain";
|
|
||||||
services.serv2 = "";
|
|
||||||
comp.render();
|
|
||||||
await nextTick();
|
|
||||||
expect(fixture.innerHTML).toBe("<div>brain serv1,serv2</div>");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("can configure an app with props", async () => {
|
|
||||||
class SomeComponent extends Component {
|
|
||||||
static template = xml`<div t-esc="props.value"/>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const app = new App(SomeComponent, { props: { value: 333 } });
|
|
||||||
await app.mount(fixture);
|
|
||||||
expect(fixture.innerHTML).toBe("<div>333</div>");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -227,38 +227,6 @@ describe("misc", () => {
|
|||||||
expect(fixture.innerHTML).toBe("<p>() => 3tostring</p>");
|
expect(fixture.innerHTML).toBe("<p>() => 3tostring</p>");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("block with 2 subblocks: variation", async () => {
|
|
||||||
const block = createBlock("<a><b><c><block-child-0/>2</c></b><block-child-1/></a>");
|
|
||||||
const tree = block([], [text("1"), text("3")]);
|
|
||||||
mount(tree, fixture);
|
|
||||||
expect(fixture.innerHTML).toBe("<a><b><c>12</c></b>3</a>");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("block with 2 subblocks: another variation", async () => {
|
|
||||||
const block = createBlock(
|
|
||||||
`<a block-attribute-0="hello"><b><c><block-child-0/>2</c></b><block-child-1/></a>`
|
|
||||||
);
|
|
||||||
const tree = block(["world"], [text("1"), text("3")]);
|
|
||||||
mount(tree, fixture);
|
|
||||||
expect(fixture.innerHTML).toBe(`<a hello="world"><b><c>12</c></b>3</a>`);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("namespace is not propagated to siblings", () => {
|
|
||||||
const block = createBlock(`<div><svg block-ns="someNameSpace"><g/></svg><div></div></div>`);
|
|
||||||
|
|
||||||
const fixture = makeTestFixture();
|
|
||||||
mount(block(), fixture);
|
|
||||||
|
|
||||||
expect(fixture.innerHTML).toBe("<div><svg><g></g></svg><div></div></div>");
|
|
||||||
expect(fixture.querySelector("svg")!.namespaceURI).toBe("someNameSpace");
|
|
||||||
expect(fixture.querySelector("g")!.namespaceURI).toBe("someNameSpace");
|
|
||||||
const allDivs = fixture.querySelectorAll("div");
|
|
||||||
expect(Array.from(allDivs).map((el) => el.namespaceURI)).toEqual([
|
|
||||||
"http://www.w3.org/1999/xhtml",
|
|
||||||
"http://www.w3.org/1999/xhtml",
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
// test.skip("reusing a block skips patching process", async () => {
|
// test.skip("reusing a block skips patching process", async () => {
|
||||||
// const block = createBlock('<div><block-text-0/></div>');
|
// const block = createBlock('<div><block-text-0/></div>');
|
||||||
// const foo = block(["foo"]);
|
// const foo = block(["foo"]);
|
||||||
|
|||||||
@@ -26,26 +26,6 @@ test("simple attribute", async () => {
|
|||||||
expect(fixture.innerHTML).toBe(`<div hello="owl"></div>`);
|
expect(fixture.innerHTML).toBe(`<div hello="owl"></div>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("updating attribute with falsy value", async () => {
|
|
||||||
const block = createBlock('<div block-attribute-0="hello"></div>');
|
|
||||||
const tree = block([false]);
|
|
||||||
|
|
||||||
mount(tree, fixture);
|
|
||||||
expect(fixture.innerHTML).toBe(`<div></div>`);
|
|
||||||
|
|
||||||
patch(tree, block(["owl"]));
|
|
||||||
expect(fixture.innerHTML).toBe(`<div hello="owl"></div>`);
|
|
||||||
|
|
||||||
patch(tree, block([false]));
|
|
||||||
expect(fixture.innerHTML).toBe(`<div></div>`);
|
|
||||||
|
|
||||||
patch(tree, block(["owl"]));
|
|
||||||
expect(fixture.innerHTML).toBe(`<div hello="owl"></div>`);
|
|
||||||
|
|
||||||
patch(tree, block([undefined]));
|
|
||||||
expect(fixture.innerHTML).toBe(`<div></div>`);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("dynamic attribute (pair)", async () => {
|
test("dynamic attribute (pair)", async () => {
|
||||||
const block = createBlock('<div block-attributes="0"></div>');
|
const block = createBlock('<div block-attributes="0"></div>');
|
||||||
const tree = block([["hello", "world"]]);
|
const tree = block([["hello", "world"]]);
|
||||||
@@ -57,20 +37,6 @@ test("dynamic attribute (pair)", async () => {
|
|||||||
expect(fixture.innerHTML).toBe(`<div ola="mundo"></div>`);
|
expect(fixture.innerHTML).toBe(`<div ola="mundo"></div>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("dynamic attribute (pair, with false value)", async () => {
|
|
||||||
const block = createBlock('<div block-attributes="0"></div>');
|
|
||||||
const tree = block([["hello", false]]);
|
|
||||||
|
|
||||||
mount(tree, fixture);
|
|
||||||
expect(fixture.innerHTML).toBe(`<div></div>`);
|
|
||||||
|
|
||||||
patch(tree, block([["hello", "world"]]));
|
|
||||||
expect(fixture.innerHTML).toBe(`<div hello="world"></div>`);
|
|
||||||
|
|
||||||
patch(tree, block([["hello", false]]));
|
|
||||||
expect(fixture.innerHTML).toBe(`<div></div>`);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("dynamic attribute (object)", async () => {
|
test("dynamic attribute (object)", async () => {
|
||||||
const block = createBlock('<div block-attributes="0"></div>');
|
const block = createBlock('<div block-attributes="0"></div>');
|
||||||
const tree = block([{ hello: "world" }]);
|
const tree = block([{ hello: "world" }]);
|
||||||
@@ -82,23 +48,6 @@ test("dynamic attribute (object)", async () => {
|
|||||||
expect(fixture.innerHTML).toBe(`<div ola="mundo"></div>`);
|
expect(fixture.innerHTML).toBe(`<div ola="mundo"></div>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("dynamic attribute (object), with falsy values", async () => {
|
|
||||||
const block = createBlock('<div block-attributes="0"></div>');
|
|
||||||
const tree = block([{ hello: "world", blip: false }]);
|
|
||||||
|
|
||||||
mount(tree, fixture);
|
|
||||||
expect(fixture.innerHTML).toBe(`<div hello="world"></div>`);
|
|
||||||
|
|
||||||
patch(tree, block([{ ola: "mundo", blip: undefined }]));
|
|
||||||
expect(fixture.innerHTML).toBe(`<div ola="mundo"></div>`);
|
|
||||||
|
|
||||||
patch(tree, block([{ ola: false, blip: 1 }]));
|
|
||||||
expect(fixture.innerHTML).toBe(`<div blip="1"></div>`);
|
|
||||||
|
|
||||||
patch(tree, block([{ ola: undefined, blip: undefined }]));
|
|
||||||
expect(fixture.innerHTML).toBe(`<div></div>`);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("class attribute", async () => {
|
test("class attribute", async () => {
|
||||||
const block = createBlock('<div block-attribute-0="class"></div>');
|
const block = createBlock('<div block-attribute-0="class"></div>');
|
||||||
const tree = block(["fire"]);
|
const tree = block(["fire"]);
|
||||||
@@ -116,14 +65,6 @@ test("class attribute", async () => {
|
|||||||
expect(fixture.innerHTML).toBe(`<div class="0"></div>`);
|
expect(fixture.innerHTML).toBe(`<div class="0"></div>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("attribute with undefined value", async () => {
|
|
||||||
const block = createBlock('<div block-attribute-0="abc"></div>');
|
|
||||||
const tree = block([undefined]);
|
|
||||||
|
|
||||||
mount(tree, fixture);
|
|
||||||
expect(fixture.innerHTML).toBe(`<div></div>`);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("class attribute with undefined value", async () => {
|
test("class attribute with undefined value", async () => {
|
||||||
const block = createBlock('<div block-attribute-0="class"></div>');
|
const block = createBlock('<div block-attribute-0="class"></div>');
|
||||||
const tree = block([undefined]);
|
const tree = block([undefined]);
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
import { comment, mount } from "../../src/blockdom";
|
|
||||||
import { makeTestFixture } from "./helpers";
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Setup and helpers
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
let fixture: HTMLElement;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = makeTestFixture();
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
fixture.remove();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("simple comment node", async () => {
|
|
||||||
const tree = comment("foo");
|
|
||||||
expect(tree.el).toBe(undefined);
|
|
||||||
mount(tree, fixture);
|
|
||||||
expect(fixture.innerHTML).toBe("<!--foo-->");
|
|
||||||
expect(tree.el).not.toBe(undefined);
|
|
||||||
tree.remove();
|
|
||||||
expect(fixture.innerHTML).toBe("");
|
|
||||||
});
|
|
||||||
@@ -76,11 +76,4 @@ describe("multi blocks", () => {
|
|||||||
mount(text(multi([text("a"), text("b")]) as any), fixture);
|
mount(text(multi([text("a"), text("b")]) as any), fixture);
|
||||||
expect(fixture.innerHTML).toBe("ab");
|
expect(fixture.innerHTML).toBe("ab");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("multi inside a block", async () => {
|
|
||||||
const block = createBlock("<div><block-child-0/></div>");
|
|
||||||
const tree = block([], [multi([text("foo"), text("bar")])]);
|
|
||||||
mount(tree, fixture);
|
|
||||||
expect(fixture.innerHTML).toBe("<div>foobar</div>");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,13 +3,14 @@
|
|||||||
exports[`attributes changing a class with t-att-class (preexisting class 1`] = `
|
exports[`attributes changing a class with t-att-class (preexisting class 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div class=\\"hoy\\" block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<div class=\\"hoy\\" block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['v'];
|
let d1 = ctx['v'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -17,13 +18,14 @@ exports[`attributes changing a class with t-att-class (preexisting class 1`] = `
|
|||||||
exports[`attributes changing a class with t-att-class 1`] = `
|
exports[`attributes changing a class with t-att-class 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['v'];
|
let d1 = ctx['v'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -31,13 +33,14 @@ exports[`attributes changing a class with t-att-class 1`] = `
|
|||||||
exports[`attributes changing an attribute with t-att- 1`] = `
|
exports[`attributes changing an attribute with t-att- 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"value\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"value\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['v'];
|
let d1 = ctx['v'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -45,13 +48,14 @@ exports[`attributes changing an attribute with t-att- 1`] = `
|
|||||||
exports[`attributes class and t-att-class should combine together 1`] = `
|
exports[`attributes class and t-att-class should combine together 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\" class=\\"hello\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\" class=\\"hello\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['value'];
|
let d1 = ctx['value'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -59,13 +63,14 @@ exports[`attributes class and t-att-class should combine together 1`] = `
|
|||||||
exports[`attributes class and t-attf-class with ternary operation 1`] = `
|
exports[`attributes class and t-attf-class with ternary operation 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div class=\\"hello\\" block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<div class=\\"hello\\" block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = (ctx['value']?'world':'');
|
let d1 = (ctx['value']?'world':'');
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -73,13 +78,14 @@ exports[`attributes class and t-attf-class with ternary operation 1`] = `
|
|||||||
exports[`attributes dynamic attribute evaluating to 0 1`] = `
|
exports[`attributes dynamic attribute evaluating to 0 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"foo\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"foo\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['value'];
|
let d1 = ctx['value'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -87,13 +93,14 @@ exports[`attributes dynamic attribute evaluating to 0 1`] = `
|
|||||||
exports[`attributes dynamic attribute falsy variable 1`] = `
|
exports[`attributes dynamic attribute falsy variable 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"foo\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"foo\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['value'];
|
let d1 = ctx['value'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -101,13 +108,14 @@ exports[`attributes dynamic attribute falsy variable 1`] = `
|
|||||||
exports[`attributes dynamic attribute with a dash 1`] = `
|
exports[`attributes dynamic attribute with a dash 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"data-action-id\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"data-action-id\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['id'];
|
let d1 = ctx['id'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -115,13 +123,14 @@ exports[`attributes dynamic attribute with a dash 1`] = `
|
|||||||
exports[`attributes dynamic attributes 1`] = `
|
exports[`attributes dynamic attributes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"foo\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"foo\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = 'bar';
|
let d1 = 'bar';
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -129,13 +138,14 @@ exports[`attributes dynamic attributes 1`] = `
|
|||||||
exports[`attributes dynamic class attribute 1`] = `
|
exports[`attributes dynamic class attribute 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['c'];
|
let d1 = ctx['c'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -143,13 +153,14 @@ exports[`attributes dynamic class attribute 1`] = `
|
|||||||
exports[`attributes dynamic class attribute evaluating to 0 1`] = `
|
exports[`attributes dynamic class attribute evaluating to 0 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['value'];
|
let d1 = ctx['value'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -157,13 +168,14 @@ exports[`attributes dynamic class attribute evaluating to 0 1`] = `
|
|||||||
exports[`attributes dynamic empty class attribute 1`] = `
|
exports[`attributes dynamic empty class attribute 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['c'];
|
let d1 = ctx['c'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -171,41 +183,14 @@ exports[`attributes dynamic empty class attribute 1`] = `
|
|||||||
exports[`attributes dynamic formatted attributes with a dash 1`] = `
|
exports[`attributes dynamic formatted attributes with a dash 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"aria-label\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"aria-label\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = \`Some text \${ctx['id']}\`;
|
let d1 = \`Some text \${ctx['id']}\`;
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`attributes dynamic undefined class attribute 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let attr1 = ctx['c'];
|
|
||||||
return block1([attr1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`attributes dynamic undefined generic attribute 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"thing\\"/>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let attr1 = ctx['c'];
|
|
||||||
return block1([attr1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -213,13 +198,14 @@ exports[`attributes dynamic undefined generic attribute 1`] = `
|
|||||||
exports[`attributes fixed variable 1`] = `
|
exports[`attributes fixed variable 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"foo\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"foo\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['value'];
|
let d1 = ctx['value'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -227,13 +213,14 @@ exports[`attributes fixed variable 1`] = `
|
|||||||
exports[`attributes format expression 1`] = `
|
exports[`attributes format expression 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"foo\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"foo\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = (ctx['value']+37);
|
let d1 = (ctx['value']+37);
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -241,13 +228,14 @@ exports[`attributes format expression 1`] = `
|
|||||||
exports[`attributes format literal 1`] = `
|
exports[`attributes format literal 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"foo\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"foo\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = \`bar\`;
|
let d1 = \`bar\`;
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -255,13 +243,14 @@ exports[`attributes format literal 1`] = `
|
|||||||
exports[`attributes format multiple 1`] = `
|
exports[`attributes format multiple 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"foo\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"foo\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = \`a \${ctx['value1']} is \${ctx['value2']} of \${ctx['value3']} ]\`;
|
let d1 = \`a \${ctx['value1']} is \${ctx['value2']} of \${ctx['value3']} ]\`;
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -269,13 +258,14 @@ exports[`attributes format multiple 1`] = `
|
|||||||
exports[`attributes format value 1`] = `
|
exports[`attributes format value 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"foo\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"foo\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = \`b\${ctx['value']}r\`;
|
let d1 = \`b\${ctx['value']}r\`;
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -283,8 +273,8 @@ exports[`attributes format value 1`] = `
|
|||||||
exports[`attributes from object variables set previously 1`] = `
|
exports[`attributes from object variables set previously 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><span block-attribute-0=\\"class\\"/></div>\`);
|
let block1 = createBlock(\`<div><span block-attribute-0=\\"class\\"/></div>\`);
|
||||||
|
|
||||||
@@ -292,8 +282,8 @@ exports[`attributes from object variables set previously 1`] = `
|
|||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"o\\", {a:'b'});
|
setContextValue(ctx, \\"o\\", {a:'b'});
|
||||||
let attr1 = ctx['o'].a;
|
let d1 = ctx['o'].a;
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -301,8 +291,8 @@ exports[`attributes from object variables set previously 1`] = `
|
|||||||
exports[`attributes from variables set previously (no external node) 1`] = `
|
exports[`attributes from variables set previously (no external node) 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<span block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
@@ -310,8 +300,8 @@ exports[`attributes from variables set previously (no external node) 1`] = `
|
|||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"abc\\", 'def');
|
setContextValue(ctx, \\"abc\\", 'def');
|
||||||
let attr1 = ctx['abc'];
|
let d1 = ctx['abc'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -319,8 +309,8 @@ exports[`attributes from variables set previously (no external node) 1`] = `
|
|||||||
exports[`attributes from variables set previously 1`] = `
|
exports[`attributes from variables set previously 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><span block-attribute-0=\\"class\\"/></div>\`);
|
let block1 = createBlock(\`<div><span block-attribute-0=\\"class\\"/></div>\`);
|
||||||
|
|
||||||
@@ -328,8 +318,8 @@ exports[`attributes from variables set previously 1`] = `
|
|||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"abc\\", 'def');
|
setContextValue(ctx, \\"abc\\", 'def');
|
||||||
let attr1 = ctx['abc'];
|
let d1 = ctx['abc'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -337,13 +327,14 @@ exports[`attributes from variables set previously 1`] = `
|
|||||||
exports[`attributes object 1`] = `
|
exports[`attributes object 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attributes=\\"0\\"/>\`);
|
let block1 = createBlock(\`<div block-attributes=\\"0\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['value'];
|
let d1 = ctx['value'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -351,7 +342,8 @@ exports[`attributes object 1`] = `
|
|||||||
exports[`attributes static attributes 1`] = `
|
exports[`attributes static attributes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div foo=\\"a\\" bar=\\"b\\" baz=\\"c\\"/>\`);
|
let block1 = createBlock(\`<div foo=\\"a\\" bar=\\"b\\" baz=\\"c\\"/>\`);
|
||||||
|
|
||||||
@@ -364,7 +356,8 @@ exports[`attributes static attributes 1`] = `
|
|||||||
exports[`attributes static attributes on void elements 1`] = `
|
exports[`attributes static attributes on void elements 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<img src=\\"/test.skip.jpg\\" alt=\\"Test\\"/>\`);
|
let block1 = createBlock(\`<img src=\\"/test.skip.jpg\\" alt=\\"Test\\"/>\`);
|
||||||
|
|
||||||
@@ -377,7 +370,8 @@ exports[`attributes static attributes on void elements 1`] = `
|
|||||||
exports[`attributes static attributes with dashes 1`] = `
|
exports[`attributes static attributes with dashes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div aria-label=\\"Close\\"/>\`);
|
let block1 = createBlock(\`<div aria-label=\\"Close\\"/>\`);
|
||||||
|
|
||||||
@@ -390,13 +384,14 @@ exports[`attributes static attributes with dashes 1`] = `
|
|||||||
exports[`attributes t-att-class and class should combine together 1`] = `
|
exports[`attributes t-att-class and class should combine together 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div class=\\"hello\\" block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<div class=\\"hello\\" block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['value'];
|
let d1 = ctx['value'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -404,13 +399,14 @@ exports[`attributes t-att-class and class should combine together 1`] = `
|
|||||||
exports[`attributes t-att-class with multiple classes 1`] = `
|
exports[`attributes t-att-class with multiple classes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = {'a b c':ctx['value']};
|
let d1 = {'a b c':ctx['value']};
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -418,13 +414,14 @@ exports[`attributes t-att-class with multiple classes 1`] = `
|
|||||||
exports[`attributes t-att-class with multiple classes 2`] = `
|
exports[`attributes t-att-class with multiple classes 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = {['a b c']:ctx['value']};
|
let d1 = {['a b c']:ctx['value']};
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -432,13 +429,14 @@ exports[`attributes t-att-class with multiple classes 2`] = `
|
|||||||
exports[`attributes t-att-class with multiple classes, some of which are duplicate 1`] = `
|
exports[`attributes t-att-class with multiple classes, some of which are duplicate 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = {'a b c':ctx['value'],'a b d':!ctx['value']};
|
let d1 = {'a b c':ctx['value'],'a b d':!ctx['value']};
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -446,13 +444,14 @@ exports[`attributes t-att-class with multiple classes, some of which are duplica
|
|||||||
exports[`attributes t-att-class with object 1`] = `
|
exports[`attributes t-att-class with object 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div class=\\"static\\" block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<div class=\\"static\\" block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = {a:ctx['b'],c:ctx['d'],e:ctx['f']};
|
let d1 = {a:ctx['b'],c:ctx['d'],e:ctx['f']};
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -460,13 +459,14 @@ exports[`attributes t-att-class with object 1`] = `
|
|||||||
exports[`attributes t-attf-class 1`] = `
|
exports[`attributes t-attf-class 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = \`hello\`;
|
let d1 = \`hello\`;
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -474,13 +474,14 @@ exports[`attributes t-attf-class 1`] = `
|
|||||||
exports[`attributes t-attf-class should combine with class 1`] = `
|
exports[`attributes t-attf-class should combine with class 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div class=\\"hello\\" block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<div class=\\"hello\\" block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = \`world\`;
|
let d1 = \`world\`;
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -488,13 +489,14 @@ exports[`attributes t-attf-class should combine with class 1`] = `
|
|||||||
exports[`attributes t-attf-class with multiple classes 1`] = `
|
exports[`attributes t-attf-class with multiple classes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = \`hello \${ctx['word']}\`;
|
let d1 = \`hello \${ctx['word']}\`;
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -502,13 +504,14 @@ exports[`attributes t-attf-class with multiple classes 1`] = `
|
|||||||
exports[`attributes t-attf-class with multiple classes separated by multiple spaces 1`] = `
|
exports[`attributes t-attf-class with multiple classes separated by multiple spaces 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = \`hello \${ctx['word']}\`;
|
let d1 = \`hello \${ctx['word']}\`;
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -516,13 +519,14 @@ exports[`attributes t-attf-class with multiple classes separated by multiple spa
|
|||||||
exports[`attributes tuple literal 1`] = `
|
exports[`attributes tuple literal 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attributes=\\"0\\"/>\`);
|
let block1 = createBlock(\`<div block-attributes=\\"0\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ['foo','bar'];
|
let d1 = ['foo','bar'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -530,13 +534,14 @@ exports[`attributes tuple literal 1`] = `
|
|||||||
exports[`attributes tuple variable 1`] = `
|
exports[`attributes tuple variable 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attributes=\\"0\\"/>\`);
|
let block1 = createBlock(\`<div block-attributes=\\"0\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['value'];
|
let d1 = ctx['value'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -544,7 +549,8 @@ exports[`attributes tuple variable 1`] = `
|
|||||||
exports[`attributes two classes 1`] = `
|
exports[`attributes two classes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div class=\\"a b\\"/>\`);
|
let block1 = createBlock(\`<div class=\\"a b\\"/>\`);
|
||||||
|
|
||||||
@@ -557,14 +563,15 @@ exports[`attributes two classes 1`] = `
|
|||||||
exports[`attributes two dynamic attributes 1`] = `
|
exports[`attributes two dynamic attributes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"foo\\" block-attribute-1=\\"bar\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"foo\\" block-attribute-1=\\"bar\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = 'bar';
|
let d1 = 'bar';
|
||||||
let attr2 = 'foo';
|
let d2 = 'foo';
|
||||||
return block1([attr1, attr2]);
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -572,13 +579,14 @@ exports[`attributes two dynamic attributes 1`] = `
|
|||||||
exports[`attributes updating classes (with obj notation) 1`] = `
|
exports[`attributes updating classes (with obj notation) 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div class=\\"hoy\\" block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<div class=\\"hoy\\" block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = {'a b':ctx['condition']};
|
let d1 = {'a b':ctx['condition']};
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -586,15 +594,16 @@ exports[`attributes updating classes (with obj notation) 1`] = `
|
|||||||
exports[`attributes various escapes 1`] = `
|
exports[`attributes various escapes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div foo=\\"<foo\\" block-attribute-0=\\"bar\\" block-attribute-1=\\"baz\\" block-attributes=\\"2\\"/>\`);
|
let block1 = createBlock(\`<div foo=\\"<foo\\" block-attribute-0=\\"bar\\" block-attribute-1=\\"baz\\" block-attributes=\\"2\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['bar'];
|
let d1 = ctx['bar'];
|
||||||
let attr2 = \`<\${ctx['baz']}>\`;
|
let d2 = \`<\${ctx['baz']}>\`;
|
||||||
let attr3 = ctx['qux'];
|
let d3 = ctx['qux'];
|
||||||
return block1([attr1, attr2, attr3]);
|
return block1([d1, d2, d3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -602,7 +611,8 @@ exports[`attributes various escapes 1`] = `
|
|||||||
exports[`attributes various escapes 2 1`] = `
|
exports[`attributes various escapes 2 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div> < </div>\`);
|
let block1 = createBlock(\`<div> < </div>\`);
|
||||||
|
|
||||||
@@ -615,13 +625,14 @@ exports[`attributes various escapes 2 1`] = `
|
|||||||
exports[`special cases for some specific html attributes/properties input of type checkbox with t-att-indeterminate 1`] = `
|
exports[`special cases for some specific html attributes/properties input of type checkbox with t-att-indeterminate 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<input type=\\"checkbox\\" block-attribute-0=\\"indeterminate\\"/>\`);
|
let block1 = createBlock(\`<input type=\\"checkbox\\" block-attribute-0=\\"indeterminate\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['v'];
|
let d1 = ctx['v'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -629,13 +640,14 @@ exports[`special cases for some specific html attributes/properties input of typ
|
|||||||
exports[`special cases for some specific html attributes/properties input type= checkbox, with t-att-checked 1`] = `
|
exports[`special cases for some specific html attributes/properties input type= checkbox, with t-att-checked 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<input type=\\"checkbox\\" block-attribute-0=\\"checked\\"/>\`);
|
let block1 = createBlock(\`<input type=\\"checkbox\\" block-attribute-0=\\"checked\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['flag'];
|
let d1 = ctx['flag'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -643,13 +655,14 @@ exports[`special cases for some specific html attributes/properties input type=
|
|||||||
exports[`special cases for some specific html attributes/properties input with t-att-value 1`] = `
|
exports[`special cases for some specific html attributes/properties input with t-att-value 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<input block-attribute-0=\\"value\\"/>\`);
|
let block1 = createBlock(\`<input block-attribute-0=\\"value\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['v'];
|
let d1 = ctx['v'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -657,13 +670,14 @@ exports[`special cases for some specific html attributes/properties input with t
|
|||||||
exports[`special cases for some specific html attributes/properties select with t-att-value 1`] = `
|
exports[`special cases for some specific html attributes/properties select with t-att-value 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<select block-attribute-0=\\"value\\"><option value=\\"potato\\">Potato</option><option value=\\"tomato\\">Tomato</option><option value=\\"onion\\">Onion</option></select>\`);
|
let block1 = createBlock(\`<select block-attribute-0=\\"value\\"><option value=\\"potato\\">Potato</option><option value=\\"tomato\\">Tomato</option><option value=\\"onion\\">Onion</option></select>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['value'];
|
let d1 = ctx['value'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -671,13 +685,14 @@ exports[`special cases for some specific html attributes/properties select with
|
|||||||
exports[`special cases for some specific html attributes/properties textarea with t-att-value 1`] = `
|
exports[`special cases for some specific html attributes/properties textarea with t-att-value 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<textarea block-attribute-0=\\"value\\"/>\`);
|
let block1 = createBlock(\`<textarea block-attribute-0=\\"value\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['v'];
|
let d1 = ctx['v'];
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -685,7 +700,8 @@ exports[`special cases for some specific html attributes/properties textarea wit
|
|||||||
exports[`special cases for some specific html attributes/properties various boolean html attributes 1`] = `
|
exports[`special cases for some specific html attributes/properties various boolean html attributes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><input type=\\"checkbox\\" checked=\\"checked\\"/><input checked=\\"checked\\"/><div checked=\\"checked\\"/><div selected=\\"selected\\"/><option selected=\\"selected\\" other=\\"1\\"/><input readonly=\\"readonly\\"/><button disabled=\\"disabled\\"/></div>\`);
|
let block1 = createBlock(\`<div><input type=\\"checkbox\\" checked=\\"checked\\"/><input checked=\\"checked\\"/><div checked=\\"checked\\"/><div selected=\\"selected\\"/><option selected=\\"selected\\" other=\\"1\\"/><input readonly=\\"readonly\\"/><button disabled=\\"disabled\\"/></div>\`);
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,13 @@
|
|||||||
exports[`comments only a comment 1`] = `
|
exports[`comments only a comment 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<!-- comment-->\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return comment(\` comment\`);
|
return block1();
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -14,7 +17,8 @@ exports[`comments only a comment 1`] = `
|
|||||||
exports[`comments properly handle comments 1`] = `
|
exports[`comments properly handle comments 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>hello <!-- comment-->owl</div>\`);
|
let block1 = createBlock(\`<div>hello <!-- comment-->owl</div>\`);
|
||||||
|
|
||||||
@@ -27,7 +31,8 @@ exports[`comments properly handle comments 1`] = `
|
|||||||
exports[`comments properly handle comments between t-if/t-else 1`] = `
|
exports[`comments properly handle comments between t-if/t-else 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
||||||
let block2 = createBlock(\`<span>true</span>\`);
|
let block2 = createBlock(\`<span>true</span>\`);
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`error handling cannot add twice the same template 1`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return block1();
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
@@ -3,13 +3,14 @@
|
|||||||
exports[`t-on can bind event handler 1`] = `
|
exports[`t-on can bind event handler 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [ctx['add'], ctx];
|
let d1 = [ctx['add'], ctx];
|
||||||
return block1([hdlr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -17,14 +18,15 @@ exports[`t-on can bind event handler 1`] = `
|
|||||||
exports[`t-on can bind handlers with arguments 1`] = `
|
exports[`t-on can bind handlers with arguments 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const v1 = ctx['add'];
|
const v1 = ctx['add'];
|
||||||
let hdlr1 = [()=>v1(5), ctx];
|
let d1 = [()=>v1(5), ctx];
|
||||||
return block1([hdlr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -32,14 +34,15 @@ exports[`t-on can bind handlers with arguments 1`] = `
|
|||||||
exports[`t-on can bind handlers with empty object 1`] = `
|
exports[`t-on can bind handlers with empty object 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const v1 = ctx['doSomething'];
|
const v1 = ctx['doSomething'];
|
||||||
let hdlr1 = [()=>v1({}), ctx];
|
let d1 = [()=>v1({}), ctx];
|
||||||
return block1([hdlr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -47,14 +50,15 @@ exports[`t-on can bind handlers with empty object 1`] = `
|
|||||||
exports[`t-on can bind handlers with empty object (with non empty inner string) 1`] = `
|
exports[`t-on can bind handlers with empty object (with non empty inner string) 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const v1 = ctx['doSomething'];
|
const v1 = ctx['doSomething'];
|
||||||
let hdlr1 = [()=>v1({}), ctx];
|
let d1 = [()=>v1({}), ctx];
|
||||||
return block1([hdlr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -62,8 +66,8 @@ exports[`t-on can bind handlers with empty object (with non empty inner string)
|
|||||||
exports[`t-on can bind handlers with empty object (with non empty inner string) 2`] = `
|
exports[`t-on can bind handlers with empty object (with non empty inner string) 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<ul><block-child-0/></ul>\`);
|
let block1 = createBlock(\`<ul><block-child-0/></ul>\`);
|
||||||
let block3 = createBlock(\`<li><a block-handler-0=\\"click\\">link</a></li>\`);
|
let block3 = createBlock(\`<li><a block-handler-0=\\"click\\">link</a></li>\`);
|
||||||
@@ -77,8 +81,8 @@ exports[`t-on can bind handlers with empty object (with non empty inner string)
|
|||||||
let key1 = ctx['action_index'];
|
let key1 = ctx['action_index'];
|
||||||
const v1 = ctx['activate'];
|
const v1 = ctx['activate'];
|
||||||
const v2 = ctx['action'];
|
const v2 = ctx['action'];
|
||||||
let hdlr1 = [()=>v1(v2), ctx];
|
let d1 = [()=>v1(v2), ctx];
|
||||||
c_block2[i1] = withKey(block3([hdlr1]), key1);
|
c_block2[i1] = withKey(block3([d1]), key1);
|
||||||
}
|
}
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
@@ -89,14 +93,15 @@ exports[`t-on can bind handlers with empty object (with non empty inner string)
|
|||||||
exports[`t-on can bind handlers with object arguments 1`] = `
|
exports[`t-on can bind handlers with object arguments 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const v1 = ctx['add'];
|
const v1 = ctx['add'];
|
||||||
let hdlr1 = [()=>v1({val:5}), ctx];
|
let d1 = [()=>v1({val:5}), ctx];
|
||||||
return block1([hdlr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -104,14 +109,15 @@ exports[`t-on can bind handlers with object arguments 1`] = `
|
|||||||
exports[`t-on can bind two event handlers 1`] = `
|
exports[`t-on can bind two event handlers 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<button block-handler-0=\\"click\\" block-handler-1=\\"dblclick\\">Click</button>\`);
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\" block-handler-1=\\"dblclick\\">Click</button>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [ctx['handleClick'], ctx];
|
let d1 = [ctx['handleClick'], ctx];
|
||||||
let hdlr2 = [ctx['handleDblClick'], ctx];
|
let d2 = [ctx['handleDblClick'], ctx];
|
||||||
return block1([hdlr1, hdlr2]);
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -119,13 +125,14 @@ exports[`t-on can bind two event handlers 1`] = `
|
|||||||
exports[`t-on handler is bound to proper owner 1`] = `
|
exports[`t-on handler is bound to proper owner 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [ctx['add'], ctx];
|
let d1 = [ctx['add'], ctx];
|
||||||
return block1([hdlr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -133,8 +140,8 @@ exports[`t-on handler is bound to proper owner 1`] = `
|
|||||||
exports[`t-on handler is bound to proper owner, part 2 1`] = `
|
exports[`t-on handler is bound to proper owner, part 2 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block2 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
let block2 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
||||||
|
|
||||||
@@ -144,8 +151,8 @@ exports[`t-on handler is bound to proper owner, part 2 1`] = `
|
|||||||
for (let i1 = 0; i1 < l_block1; i1++) {
|
for (let i1 = 0; i1 < l_block1; i1++) {
|
||||||
ctx[\`value\`] = v_block1[i1];
|
ctx[\`value\`] = v_block1[i1];
|
||||||
let key1 = ctx['value'];
|
let key1 = ctx['value'];
|
||||||
let hdlr1 = [ctx['add'], ctx];
|
let d1 = [ctx['add'], ctx];
|
||||||
c_block1[i1] = withKey(block2([hdlr1]), key1);
|
c_block1[i1] = withKey(block2([d1]), key1);
|
||||||
}
|
}
|
||||||
return list(c_block1);
|
return list(c_block1);
|
||||||
}
|
}
|
||||||
@@ -155,12 +162,14 @@ exports[`t-on handler is bound to proper owner, part 2 1`] = `
|
|||||||
exports[`t-on handler is bound to proper owner, part 3 1`] = `
|
exports[`t-on handler is bound to proper owner, part 3 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { getTemplate } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`sub\`);
|
|
||||||
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
let d1 = [ctx['add'], ctx];
|
||||||
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -168,13 +177,12 @@ exports[`t-on handler is bound to proper owner, part 3 1`] = `
|
|||||||
exports[`t-on handler is bound to proper owner, part 3 2`] = `
|
exports[`t-on handler is bound to proper owner, part 3 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
const callTemplate_2 = getTemplate(\`sub\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [ctx['add'], ctx];
|
return callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||||
return block1([hdlr1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -182,9 +190,24 @@ exports[`t-on handler is bound to proper owner, part 3 2`] = `
|
|||||||
exports[`t-on handler is bound to proper owner, part 4 1`] = `
|
exports[`t-on handler is bound to proper owner, part 4 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, getTemplate, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`sub\`);
|
|
||||||
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = [ctx['add'], ctx];
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`t-on handler is bound to proper owner, part 4 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
const callTemplate_2 = getTemplate(\`sub\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
@@ -196,37 +219,24 @@ exports[`t-on handler is bound to proper owner, part 4 1`] = `
|
|||||||
ctx[\`value_index\`] = i1;
|
ctx[\`value_index\`] = i1;
|
||||||
ctx[\`value_value\`] = k_block1[i1];
|
ctx[\`value_value\`] = k_block1[i1];
|
||||||
let key1 = ctx['value'];
|
let key1 = ctx['value'];
|
||||||
c_block1[i1] = withKey(callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`), key1);
|
c_block1[i1] = withKey(callTemplate_2.call(this, ctx, node, key + \`__1__\${key1}\`), key1);
|
||||||
}
|
}
|
||||||
return list(c_block1);
|
return list(c_block1);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-on handler is bound to proper owner, part 4 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let hdlr1 = [ctx['add'], ctx];
|
|
||||||
return block1([hdlr1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-on receive event in first argument 1`] = `
|
exports[`t-on receive event in first argument 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [ctx['add'], ctx];
|
let d1 = [ctx['add'], ctx];
|
||||||
return block1([hdlr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -234,14 +244,15 @@ exports[`t-on receive event in first argument 1`] = `
|
|||||||
exports[`t-on t-on modifiers (native listener) basic support for native listener 1`] = `
|
exports[`t-on t-on modifiers (native listener) basic support for native listener 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div class=\\"myClass\\" block-handler-0=\\"click\\"><button block-handler-1=\\"click\\">Button</button></div>\`);
|
let block1 = createBlock(\`<div class=\\"myClass\\" block-handler-0=\\"click\\"><button block-handler-1=\\"click\\">Button</button></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [ctx['divClicked'], ctx];
|
let d1 = [ctx['divClicked'], ctx];
|
||||||
let hdlr2 = [ctx['btnClicked'], ctx];
|
let d2 = [ctx['btnClicked'], ctx];
|
||||||
return block1([hdlr1, hdlr2]);
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -249,14 +260,15 @@ exports[`t-on t-on modifiers (native listener) basic support for native listener
|
|||||||
exports[`t-on t-on modifiers (native listener) t-on combined with t-esc 1`] = `
|
exports[`t-on t-on modifiers (native listener) t-on combined with t-esc 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><button block-handler-0=\\"click\\"><block-text-1/></button></div>\`);
|
let block1 = createBlock(\`<div><button block-handler-0=\\"click\\"><block-text-1/></button></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [ctx['onClick'], ctx];
|
let d1 = [ctx['onClick'], ctx];
|
||||||
let txt1 = ctx['text'];
|
let d2 = ctx['text'];
|
||||||
return block1([hdlr1, txt1]);
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -264,15 +276,15 @@ exports[`t-on t-on modifiers (native listener) t-on combined with t-esc 1`] = `
|
|||||||
exports[`t-on t-on modifiers (native listener) t-on combined with t-out 1`] = `
|
exports[`t-on t-on modifiers (native listener) t-on combined with t-out 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><button block-handler-0=\\"click\\"><block-child-0/></button></div>\`);
|
let block1 = createBlock(\`<div><button block-handler-0=\\"click\\"><block-child-0/></button></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [ctx['onClick'], ctx];
|
let d1 = [ctx['onClick'], ctx];
|
||||||
let b2 = safeOutput(ctx['html']);
|
let b2 = safeOutput(ctx['html']);
|
||||||
return block1([hdlr1], [b2]);
|
return block1([d1], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -280,14 +292,15 @@ exports[`t-on t-on modifiers (native listener) t-on combined with t-out 1`] = `
|
|||||||
exports[`t-on t-on modifiers (native listener) t-on with .capture modifier 1`] = `
|
exports[`t-on t-on modifiers (native listener) t-on with .capture modifier 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-handler-0=\\"click.capture\\"><button block-handler-1=\\"click\\">Button</button></div>\`);
|
let block1 = createBlock(\`<div block-handler-0=\\"click.capture\\"><button block-handler-1=\\"click\\">Button</button></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [\\"capture\\", ctx['onCapture'], ctx];
|
let d1 = [\\"capture\\", ctx['onCapture'], ctx];
|
||||||
let hdlr2 = [ctx['doSomething'], ctx];
|
let d2 = [ctx['doSomething'], ctx];
|
||||||
return block1([hdlr1, hdlr2]);
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -295,13 +308,14 @@ exports[`t-on t-on modifiers (native listener) t-on with .capture modifier 1`] =
|
|||||||
exports[`t-on t-on modifiers (native listener) t-on with empty handler (only modifiers) 1`] = `
|
exports[`t-on t-on modifiers (native listener) t-on with empty handler (only modifiers) 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><button block-handler-0=\\"click.prevent\\">Button</button></div>\`);
|
let block1 = createBlock(\`<div><button block-handler-0=\\"click.prevent\\">Button</button></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [\\"prevent\\", , ctx];
|
let d1 = [\\"prevent\\", , ctx];
|
||||||
return block1([hdlr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -309,13 +323,14 @@ exports[`t-on t-on modifiers (native listener) t-on with empty handler (only mod
|
|||||||
exports[`t-on t-on modifiers (native listener) t-on with prevent and self modifiers (order matters) 1`] = `
|
exports[`t-on t-on modifiers (native listener) t-on with prevent and self modifiers (order matters) 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><button block-handler-0=\\"click.prevent.self\\"><span>Button</span></button></div>\`);
|
let block1 = createBlock(\`<div><button block-handler-0=\\"click.prevent.self\\"><span>Button</span></button></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [\\"prevent\\",\\"self\\", ctx['onClick'], ctx];
|
let d1 = [\\"prevent\\",\\"self\\", ctx['onClick'], ctx];
|
||||||
return block1([hdlr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -323,15 +338,16 @@ exports[`t-on t-on modifiers (native listener) t-on with prevent and self modifi
|
|||||||
exports[`t-on t-on modifiers (native listener) t-on with prevent and/or stop modifiers 1`] = `
|
exports[`t-on t-on modifiers (native listener) t-on with prevent and/or stop modifiers 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><button block-handler-0=\\"click.prevent\\">Button 1</button><button block-handler-1=\\"click.stop\\">Button 2</button><button block-handler-2=\\"click.prevent.stop\\">Button 3</button></div>\`);
|
let block1 = createBlock(\`<div><button block-handler-0=\\"click.prevent\\">Button 1</button><button block-handler-1=\\"click.stop\\">Button 2</button><button block-handler-2=\\"click.prevent.stop\\">Button 3</button></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [\\"prevent\\", ctx['onClickPrevented'], ctx];
|
let d1 = [\\"prevent\\", ctx['onClickPrevented'], ctx];
|
||||||
let hdlr2 = [\\"stop\\", ctx['onClickStopped'], ctx];
|
let d2 = [\\"stop\\", ctx['onClickStopped'], ctx];
|
||||||
let hdlr3 = [\\"prevent\\",\\"stop\\", ctx['onClickPreventedAndStopped'], ctx];
|
let d3 = [\\"prevent\\",\\"stop\\", ctx['onClickPreventedAndStopped'], ctx];
|
||||||
return block1([hdlr1, hdlr2, hdlr3]);
|
return block1([d1, d2, d3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -339,8 +355,8 @@ exports[`t-on t-on modifiers (native listener) t-on with prevent and/or stop mod
|
|||||||
exports[`t-on t-on modifiers (native listener) t-on with prevent modifier in t-foreach 1`] = `
|
exports[`t-on t-on modifiers (native listener) t-on with prevent modifier in t-foreach 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block3 = createBlock(\`<a href=\\"#\\" block-handler-0=\\"click.prevent\\"> Edit <block-text-1/></a>\`);
|
let block3 = createBlock(\`<a href=\\"#\\" block-handler-0=\\"click.prevent\\"> Edit <block-text-1/></a>\`);
|
||||||
@@ -353,9 +369,9 @@ exports[`t-on t-on modifiers (native listener) t-on with prevent modifier in t-f
|
|||||||
let key1 = ctx['project'];
|
let key1 = ctx['project'];
|
||||||
const v1 = ctx['onEdit'];
|
const v1 = ctx['onEdit'];
|
||||||
const v2 = ctx['project'];
|
const v2 = ctx['project'];
|
||||||
let hdlr1 = [\\"prevent\\", ev=>v1(v2.id,ev), ctx];
|
let d1 = [\\"prevent\\", ev=>v1(v2.id,ev), ctx];
|
||||||
let txt1 = ctx['project'].name;
|
let d2 = ctx['project'].name;
|
||||||
c_block2[i1] = withKey(block3([hdlr1, txt1]), key1);
|
c_block2[i1] = withKey(block3([d1, d2]), key1);
|
||||||
}
|
}
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
@@ -366,13 +382,14 @@ exports[`t-on t-on modifiers (native listener) t-on with prevent modifier in t-f
|
|||||||
exports[`t-on t-on modifiers (native listener) t-on with self and prevent modifiers (order matters) 1`] = `
|
exports[`t-on t-on modifiers (native listener) t-on with self and prevent modifiers (order matters) 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><button block-handler-0=\\"click.self.prevent\\"><span>Button</span></button></div>\`);
|
let block1 = createBlock(\`<div><button block-handler-0=\\"click.self.prevent\\"><span>Button</span></button></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [\\"self\\",\\"prevent\\", ctx['onClick'], ctx];
|
let d1 = [\\"self\\",\\"prevent\\", ctx['onClick'], ctx];
|
||||||
return block1([hdlr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -380,14 +397,15 @@ exports[`t-on t-on modifiers (native listener) t-on with self and prevent modifi
|
|||||||
exports[`t-on t-on modifiers (native listener) t-on with self modifier 1`] = `
|
exports[`t-on t-on modifiers (native listener) t-on with self modifier 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><button block-handler-0=\\"click\\"><span>Button</span></button><button block-handler-1=\\"click.self\\"><span>Button</span></button></div>\`);
|
let block1 = createBlock(\`<div><button block-handler-0=\\"click\\"><span>Button</span></button><button block-handler-1=\\"click.self\\"><span>Button</span></button></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [ctx['onClick'], ctx];
|
let d1 = [ctx['onClick'], ctx];
|
||||||
let hdlr2 = [\\"self\\", ctx['onClickSelf'], ctx];
|
let d2 = [\\"self\\", ctx['onClickSelf'], ctx];
|
||||||
return block1([hdlr1, hdlr2]);
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -395,14 +413,15 @@ exports[`t-on t-on modifiers (native listener) t-on with self modifier 1`] = `
|
|||||||
exports[`t-on t-on modifiers (synthetic listener) basic support for synthetic 1`] = `
|
exports[`t-on t-on modifiers (synthetic listener) basic support for synthetic 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-handler-0=\\"click.synthetic\\"><button block-handler-1=\\"click.synthetic\\">Button</button></div>\`);
|
let block1 = createBlock(\`<div block-handler-0=\\"click.synthetic\\"><button block-handler-1=\\"click.synthetic\\">Button</button></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [\\"synthetic\\", ctx['divClicked'], ctx];
|
let d1 = [\\"synthetic\\", ctx['divClicked'], ctx];
|
||||||
let hdlr2 = [\\"synthetic\\", ctx['btnClicked'], ctx];
|
let d2 = [\\"synthetic\\", ctx['btnClicked'], ctx];
|
||||||
return block1([hdlr1, hdlr2]);
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -410,14 +429,15 @@ exports[`t-on t-on modifiers (synthetic listener) basic support for synthetic 1`
|
|||||||
exports[`t-on t-on with inline statement (function call) 1`] = `
|
exports[`t-on t-on with inline statement (function call) 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const v1 = ctx['state'];
|
const v1 = ctx['state'];
|
||||||
let hdlr1 = [()=>v1.incrementCounter(2), ctx];
|
let d1 = [()=>v1.incrementCounter(2), ctx];
|
||||||
return block1([hdlr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -425,14 +445,15 @@ exports[`t-on t-on with inline statement (function call) 1`] = `
|
|||||||
exports[`t-on t-on with inline statement 1`] = `
|
exports[`t-on t-on with inline statement 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const v1 = ctx['state'];
|
const v1 = ctx['state'];
|
||||||
let hdlr1 = [()=>v1.counter++, ctx];
|
let d1 = [()=>v1.counter++, ctx];
|
||||||
return block1([hdlr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -440,14 +461,15 @@ exports[`t-on t-on with inline statement 1`] = `
|
|||||||
exports[`t-on t-on with inline statement, part 2 1`] = `
|
exports[`t-on t-on with inline statement, part 2 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Toggle</button>\`);
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Toggle</button>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const v1 = ctx['state'];
|
const v1 = ctx['state'];
|
||||||
let hdlr1 = [()=>v1.flag=!v1.flag, ctx];
|
let d1 = [()=>v1.flag=!v1.flag, ctx];
|
||||||
return block1([hdlr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -455,15 +477,16 @@ exports[`t-on t-on with inline statement, part 2 1`] = `
|
|||||||
exports[`t-on t-on with inline statement, part 3 1`] = `
|
exports[`t-on t-on with inline statement, part 3 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Toggle</button>\`);
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Toggle</button>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const v1 = ctx['state'];
|
const v1 = ctx['state'];
|
||||||
const v2 = ctx['someFunction'];
|
const v2 = ctx['someFunction'];
|
||||||
let hdlr1 = [()=>v1.n=v2(3), ctx];
|
let d1 = [()=>v1.n=v2(3), ctx];
|
||||||
return block1([hdlr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -471,15 +494,14 @@ exports[`t-on t-on with inline statement, part 3 1`] = `
|
|||||||
exports[`t-on t-on with t-call 1`] = `
|
exports[`t-on t-on with t-call 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { getTemplate } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`sub\`);
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<p block-handler-0=\\"click\\">lucas</p>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
let d1 = [ctx['update'], ctx];
|
||||||
return block1([], [b2]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -487,13 +509,15 @@ exports[`t-on t-on with t-call 1`] = `
|
|||||||
exports[`t-on t-on with t-call 2`] = `
|
exports[`t-on t-on with t-call 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
const callTemplate_2 = getTemplate(\`sub\`);
|
||||||
|
|
||||||
let block1 = createBlock(\`<p block-handler-0=\\"click\\">lucas</p>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [ctx['update'], ctx];
|
let b2 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||||
return block1([hdlr1]);
|
return block1([], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -501,15 +525,15 @@ exports[`t-on t-on with t-call 2`] = `
|
|||||||
exports[`t-on t-on, with arguments and t-call 1`] = `
|
exports[`t-on t-on, with arguments and t-call 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { getTemplate } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`sub\`);
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<p block-handler-0=\\"click\\">lucas</p>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
const v1 = ctx['value'];
|
||||||
return block1([], [b2]);
|
let d1 = [()=>this.update(v1), ctx];
|
||||||
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -517,14 +541,15 @@ exports[`t-on t-on, with arguments and t-call 1`] = `
|
|||||||
exports[`t-on t-on, with arguments and t-call 2`] = `
|
exports[`t-on t-on, with arguments and t-call 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
const callTemplate_2 = getTemplate(\`sub\`);
|
||||||
|
|
||||||
let block1 = createBlock(\`<p block-handler-0=\\"click\\">lucas</p>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const v1 = ctx['value'];
|
let b2 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||||
let hdlr1 = [()=>this.update(v1), ctx];
|
return block1([], [b2]);
|
||||||
return block1([hdlr1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
exports[`misc complex template 1`] = `
|
exports[`misc complex template 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"><div block-attribute-1=\\"class\\"><div class=\\"batch_header\\"><a block-attribute-2=\\"href\\" block-attribute-3=\\"class\\" title=\\"View Batch\\"><block-text-4/><block-child-0/><i class=\\"arrow fa fa-window-maximize\\"/></a></div><block-child-1/><div class=\\"batch_slots\\"><block-child-2/><block-child-3/></div><div class=\\"batch_commits\\"><block-child-4/></div></div></div>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"><div block-attribute-1=\\"class\\"><div class=\\"batch_header\\"><a block-attribute-2=\\"href\\" block-attribute-3=\\"class\\" title=\\"View Batch\\"><block-text-4/><block-child-0/><i class=\\"arrow fa fa-window-maximize\\"/></a></div><block-child-1/><div class=\\"batch_slots\\"><block-child-2/><block-child-3/></div><div class=\\"batch_commits\\"><block-child-4/></div></div></div>\`);
|
||||||
let block2 = createBlock(\`<i class=\\"fa fa-exclamation-triangle\\"/>\`);
|
let block2 = createBlock(\`<i class=\\"fa fa-exclamation-triangle\\"/>\`);
|
||||||
@@ -18,11 +18,11 @@ exports[`misc complex template 1`] = `
|
|||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2,b3,b4,b6,b8;
|
let b2,b3,b4,b6,b8;
|
||||||
let attr1 = \`batch_tile \${ctx['options'].more?'more':'nomore'}\`;
|
let d1 = \`batch_tile \${ctx['options'].more?'more':'nomore'}\`;
|
||||||
let attr2 = \`card bg-\${ctx['klass']}-light\`;
|
let d2 = \`card bg-\${ctx['klass']}-light\`;
|
||||||
let attr3 = \`/runbot/batch/\${ctx['batch'].id}\`;
|
let d3 = \`/runbot/batch/\${ctx['batch'].id}\`;
|
||||||
let attr4 = \`badge badge-\${ctx['batch'].has_warning?'warning':'light'}\`;
|
let d4 = \`badge badge-\${ctx['batch'].has_warning?'warning':'light'}\`;
|
||||||
let txt1 = ctx['batch'].formated_age;
|
let d5 = ctx['batch'].formated_age;
|
||||||
if (ctx['batch'].has_warning) {
|
if (ctx['batch'].has_warning) {
|
||||||
b2 = block2();
|
b2 = block2();
|
||||||
}
|
}
|
||||||
@@ -53,8 +53,8 @@ exports[`misc complex template 1`] = `
|
|||||||
ctx[\`commit_link\`] = v_block8[i1];
|
ctx[\`commit_link\`] = v_block8[i1];
|
||||||
let key1 = ctx['commit_link'].id;
|
let key1 = ctx['commit_link'].id;
|
||||||
let b10,b11,b12,b13;
|
let b10,b11,b12,b13;
|
||||||
let attr5 = \`/runbot/commit/\${ctx['commit_link'].commit_id}\`;
|
let d6 = \`/runbot/commit/\${ctx['commit_link'].commit_id}\`;
|
||||||
let attr6 = \`badge badge-light batch_commit match_type_\${ctx['commit_link'].match_type}\`;
|
let d7 = \`badge badge-light batch_commit match_type_\${ctx['commit_link'].match_type}\`;
|
||||||
if (ctx['commit_link'].match_type=='new') {
|
if (ctx['commit_link'].match_type=='new') {
|
||||||
b10 = block10();
|
b10 = block10();
|
||||||
}
|
}
|
||||||
@@ -67,13 +67,13 @@ exports[`misc complex template 1`] = `
|
|||||||
if (ctx['commit_link'].match_type=='base_head') {
|
if (ctx['commit_link'].match_type=='base_head') {
|
||||||
b13 = block13();
|
b13 = block13();
|
||||||
}
|
}
|
||||||
let txt2 = ctx['commit_link'].commit_dname;
|
let d8 = ctx['commit_link'].commit_dname;
|
||||||
let attr7 = 'https://%s/commit/%s'%(ctx['commit_link'].commit_remote_url,ctx['commit_link'].commit_name);
|
let d9 = 'https://%s/commit/%s'%(ctx['commit_link'].commit_remote_url,ctx['commit_link'].commit_name);
|
||||||
let txt3 = ctx['commit_link'].commit_subject;
|
let d10 = ctx['commit_link'].commit_subject;
|
||||||
c_block8[i1] = withKey(block9([attr5, attr6, txt2, attr7, txt3], [b10, b11, b12, b13]), key1);
|
c_block8[i1] = withKey(block9([d6, d7, d8, d9, d10], [b10, b11, b12, b13]), key1);
|
||||||
}
|
}
|
||||||
b8 = list(c_block8);
|
b8 = list(c_block8);
|
||||||
return block1([attr1, attr2, attr3, attr4, txt1], [b2, b3, b4, b6, b8]);
|
return block1([d1, d2, d3, d4, d5], [b2, b3, b4, b6, b8]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -81,13 +81,60 @@ exports[`misc complex template 1`] = `
|
|||||||
exports[`misc global 1`] = `
|
exports[`misc global 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, isBoundary, withDefault, setContextValue, getTemplate, zero, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`_callee-uses-foo\`);
|
|
||||||
|
let block1 = createBlock(\`<año block-attribute-0=\\"falló\\"><block-child-0/></año>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = 'agüero';
|
||||||
|
let b2 = ctx[zero];
|
||||||
|
return block1([d1], [b2]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`misc global 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = withDefault(ctx['foo'], \`foo default\`);
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`misc global 3`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let b3 = text(\`toto default\`);
|
||||||
|
let b2 = withDefault(safeOutput(ctx['toto']), b3);
|
||||||
|
return block1([], [b2]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`misc global 4`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_2 = getTemplate(\`_callee-uses-foo\`);
|
const callTemplate_2 = getTemplate(\`_callee-uses-foo\`);
|
||||||
const callTemplate_3 = getTemplate(\`_callee-uses-foo\`);
|
const callTemplate_4 = getTemplate(\`_callee-uses-foo\`);
|
||||||
const callTemplate_4 = getTemplate(\`_callee-asc\`);
|
const callTemplate_6 = getTemplate(\`_callee-uses-foo\`);
|
||||||
const callTemplate_5 = getTemplate(\`_callee-asc-toto\`);
|
const callTemplate_8 = getTemplate(\`_callee-asc\`);
|
||||||
|
const callTemplate_10 = getTemplate(\`_callee-asc-toto\`);
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
||||||
let block4 = createBlock(\`<span><block-text-0/></span>\`);
|
let block4 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
@@ -104,85 +151,38 @@ exports[`misc global 1`] = `
|
|||||||
ctx[\`value_index\`] = i1;
|
ctx[\`value_index\`] = i1;
|
||||||
ctx[\`value_value\`] = k_block2[i1];
|
ctx[\`value_value\`] = k_block2[i1];
|
||||||
let key1 = ctx['value'];
|
let key1 = ctx['value'];
|
||||||
let txt1 = ctx['value'];
|
let d1 = ctx['value'];
|
||||||
let b4 = block4([txt1]);
|
let b4 = block4([d1]);
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1;
|
ctx[isBoundary] = 1;
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1;
|
ctx[isBoundary] = 1;
|
||||||
setContextValue(ctx, \\"foo\\", 'aaa');
|
setContextValue(ctx, \\"foo\\", 'aaa');
|
||||||
let b6 = callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`);
|
let b6 = callTemplate_2.call(this, ctx, node, key + \`__1__\${key1}\`);
|
||||||
ctx = ctx.__proto__;
|
ctx = ctx.__proto__;
|
||||||
let b7 = callTemplate_2.call(this, ctx, node, key + \`__2__\${key1}\`);
|
let b7 = callTemplate_4.call(this, ctx, node, key + \`__3__\${key1}\`);
|
||||||
setContextValue(ctx, \\"foo\\", 'bbb');
|
setContextValue(ctx, \\"foo\\", 'bbb');
|
||||||
let b8 = callTemplate_3.call(this, ctx, node, key + \`__3__\${key1}\`);
|
let b8 = callTemplate_6.call(this, ctx, node, key + \`__5__\${key1}\`);
|
||||||
let b5 = multi([b6, b7, b8]);
|
let b5 = multi([b6, b7, b8]);
|
||||||
ctx[zero] = b5;
|
ctx[zero] = b5;
|
||||||
let b9 = callTemplate_4.call(this, ctx, node, key + \`__4__\${key1}\`);
|
let b9 = callTemplate_8.call(this, ctx, node, key + \`__7__\${key1}\`);
|
||||||
ctx = ctx.__proto__;
|
ctx = ctx.__proto__;
|
||||||
c_block2[i1] = withKey(multi([b4, b9]), key1);
|
c_block2[i1] = withKey(multi([b4, b9]), key1);
|
||||||
}
|
}
|
||||||
ctx = ctx.__proto__;
|
ctx = ctx.__proto__;
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
let b10 = callTemplate_5.call(this, ctx, node, key + \`__5\`);
|
let b10 = callTemplate_10.call(this, ctx, node, key + \`__9\`);
|
||||||
return block1([], [b2, b10]);
|
return block1([], [b2, b10]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`misc global 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { withDefault } = helpers;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = withDefault(ctx['foo'], \`foo default\`);
|
|
||||||
return block1([txt1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`misc global 3`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { zero } = helpers;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<año block-attribute-0=\\"falló\\"><block-child-0/></año>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let attr1 = 'agüero';
|
|
||||||
let b2 = ctx[zero];
|
|
||||||
return block1([attr1], [b2]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`misc global 4`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { safeOutput, withDefault } = helpers;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let b3 = text(\`toto default\`);
|
|
||||||
let b2 = withDefault(safeOutput(ctx['toto']), b3);
|
|
||||||
return block1([], [b2]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`misc other complex template 1`] = `
|
exports[`misc other complex template 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey, getTemplate } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`LOAD_INFOS_TEMPLATE\`);
|
const callTemplate_2 = getTemplate(\`LOAD_INFOS_TEMPLATE\`);
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><header><nav class=\\"navbar navbar-expand-md navbar-light bg-light\\"><a block-attribute-0=\\"href\\"><b style=\\"color:#777;\\"><block-text-1/></b></a><button type=\\"button\\" class=\\"navbar-toggler\\" data-toggle=\\"collapse\\" data-target=\\"#top_menu_collapse\\"><span class=\\"navbar-toggler-icon\\"/></button><div class=\\"collapse navbar-collapse\\" id=\\"top_menu_collapse\\" aria-expanded=\\"false\\"><ul class=\\"nav navbar-nav ml-auto text-right\\" id=\\"top_menu\\"><block-child-0/><li class=\\"nav-item divider\\"/><block-child-1/></ul><div><div class=\\"input-group input-group-sm\\"><div class=\\"input-group-prepend input-group-sm\\"><button class=\\"btn btn-default fa fa-cog\\" title=\\"Settings\\" block-handler-2=\\"click\\"/><button class=\\"btn btn-default\\" block-handler-3=\\"click\\"> More </button><block-child-2/></div><input class=\\"form-control\\" type=\\"text\\" placeholder=\\"Search\\" aria-label=\\"Search\\" name=\\"search\\" block-attribute-4=\\"value\\" block-handler-5=\\"keyup\\" block-handler-6=\\"change\\" block-ref=\\"7\\"/><div class=\\"input-group-append\\"><button class=\\"btn btn-default fa fa-eraser\\" block-handler-8=\\"click\\"/></div></div></div></div></nav></header><div class=\\"container-fluid\\" block-ref=\\"9\\"><div class=\\"row\\"><!--div class=\\"form-group col-md-6\\">
|
let block1 = createBlock(\`<div><header><nav class=\\"navbar navbar-expand-md navbar-light bg-light\\"><a block-attribute-0=\\"href\\"><b style=\\"color:#777;\\"><block-text-1/></b></a><button type=\\"button\\" class=\\"navbar-toggler\\" data-toggle=\\"collapse\\" data-target=\\"#top_menu_collapse\\"><span class=\\"navbar-toggler-icon\\"/></button><div class=\\"collapse navbar-collapse\\" id=\\"top_menu_collapse\\" aria-expanded=\\"false\\"><ul class=\\"nav navbar-nav ml-auto text-right\\" id=\\"top_menu\\"><block-child-0/><li class=\\"nav-item divider\\"/><block-child-1/></ul><div><div class=\\"input-group input-group-sm\\"><div class=\\"input-group-prepend input-group-sm\\"><button class=\\"btn btn-default fa fa-cog\\" title=\\"Settings\\" block-handler-2=\\"click\\"/><button class=\\"btn btn-default\\" block-handler-3=\\"click\\"> More </button><block-child-2/></div><input class=\\"form-control\\" type=\\"text\\" placeholder=\\"Search\\" aria-label=\\"Search\\" name=\\"search\\" block-attribute-4=\\"value\\" block-handler-5=\\"keyup\\" block-handler-6=\\"change\\" block-ref=\\"7\\"/><div class=\\"input-group-append\\"><button class=\\"btn btn-default fa fa-eraser\\" block-handler-8=\\"click\\"/></div></div></div></div></nav></header><div class=\\"container-fluid\\" block-ref=\\"9\\"><div class=\\"row\\"><!--div class=\\"form-group col-md-6\\">
|
||||||
<h5>Search options</h5>
|
<h5>Search options</h5>
|
||||||
@@ -215,33 +215,31 @@ exports[`misc other complex template 1`] = `
|
|||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const refs = ctx.__owl__.refs;
|
const refs = ctx.__owl__.refs;
|
||||||
const ref1 = (el) => refs[\`search_input\`] = el;
|
|
||||||
const ref2 = (el) => refs[\`settings_menu\`] = el;
|
|
||||||
let b2,b4,b14,b17,b22,b23,b24,b25;
|
let b2,b4,b14,b17,b22,b23,b24,b25;
|
||||||
let attr1 = \`/runbot/\${ctx['project'].slug}\`;
|
let d1 = \`/runbot/\${ctx['project'].slug}\`;
|
||||||
let txt1 = ctx['project'].name;
|
let d2 = ctx['project'].name;
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['projects']);
|
const [k_block2, v_block2, l_block2, c_block2] = prepareList(ctx['projects']);
|
||||||
for (let i1 = 0; i1 < l_block2; i1++) {
|
for (let i1 = 0; i1 < l_block2; i1++) {
|
||||||
ctx[\`project\`] = v_block2[i1];
|
ctx[\`project\`] = v_block2[i1];
|
||||||
let key1 = ctx['project'].id;
|
let key1 = ctx['project'].id;
|
||||||
let hdlr1 = [ctx['selectProject'](ctx['project']), ctx];
|
let d3 = [ctx['selectProject'](ctx['project']), ctx];
|
||||||
let txt2 = ctx['project'].name;
|
let d4 = ctx['project'].name;
|
||||||
c_block2[i1] = withKey(block3([hdlr1, txt2]), key1);
|
c_block2[i1] = withKey(block3([d3, d4]), key1);
|
||||||
}
|
}
|
||||||
ctx = ctx.__proto__;
|
ctx = ctx.__proto__;
|
||||||
b2 = list(c_block2);
|
b2 = list(c_block2);
|
||||||
if (ctx['user']) {
|
if (ctx['user']) {
|
||||||
let b5,b6;
|
let b5,b6;
|
||||||
if (ctx['user'].public) {
|
if (ctx['user'].public) {
|
||||||
let attr2 = \`/web/login?redirect=/\`;
|
let d5 = \`/web/login?redirect=/\`;
|
||||||
b5 = block5([attr2]);
|
b5 = block5([d5]);
|
||||||
} else {
|
} else {
|
||||||
let b7,b10,b13;
|
let b7,b10,b13;
|
||||||
if (ctx['nb_assigned_errors']&&ctx['nb_assigned_errors']>0) {
|
if (ctx['nb_assigned_errors']&&ctx['nb_assigned_errors']>0) {
|
||||||
let attr3 = \`You have \${ctx['nb_assigned_errors']} random bug assigned\`;
|
let d6 = \`You have \${ctx['nb_assigned_errors']} random bug assigned\`;
|
||||||
let txt3 = ctx['nb_assigned_errors'];
|
let d7 = ctx['nb_assigned_errors'];
|
||||||
let b8 = block8([attr3, txt3]);
|
let b8 = block8([d6, d7]);
|
||||||
let b9 = block9();
|
let b9 = block9();
|
||||||
b7 = multi([b8, b9]);
|
b7 = multi([b8, b9]);
|
||||||
} else if (ctx['nb_build_errors']&&ctx['nb_build_errors']>0) {
|
} else if (ctx['nb_build_errors']&&ctx['nb_build_errors']>0) {
|
||||||
@@ -249,35 +247,37 @@ exports[`misc other complex template 1`] = `
|
|||||||
let b12 = block12();
|
let b12 = block12();
|
||||||
b10 = multi([b11, b12]);
|
b10 = multi([b11, b12]);
|
||||||
}
|
}
|
||||||
let txt4 = ctx['user'].name.length>25?ctx['user'].namesubstring(0,23)+'...':ctx['user'].name;
|
let d8 = ctx['user'].name.length>25?ctx['user'].namesubstring(0,23)+'...':ctx['user'].name;
|
||||||
let attr4 = \`/web/session/logout?redirect=/\`;
|
let d9 = \`/web/session/logout?redirect=/\`;
|
||||||
let attr5 = \`/web\`;
|
let d10 = \`/web\`;
|
||||||
b13 = block13([txt4, attr4, attr5]);
|
b13 = block13([d8, d9, d10]);
|
||||||
b6 = multi([b7, b10, b13]);
|
b6 = multi([b7, b10, b13]);
|
||||||
}
|
}
|
||||||
b4 = multi([b5, b6]);
|
b4 = multi([b5, b6]);
|
||||||
}
|
}
|
||||||
let hdlr2 = [ctx['toggleSettingsMenu'], ctx];
|
let d11 = [ctx['toggleSettingsMenu'], ctx];
|
||||||
let hdlr3 = [ctx['toggleMore'], ctx];
|
let d12 = [ctx['toggleMore'], ctx];
|
||||||
if (ctx['categories']&&ctx['categories'].length>1) {
|
if (ctx['categories']&&ctx['categories'].length>1) {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
const [k_block15, v_block15, l_block15, c_block15] = prepareList(ctx['categories']);
|
const [k_block15, v_block15, l_block15, c_block15] = prepareList(ctx['categories']);
|
||||||
for (let i1 = 0; i1 < l_block15; i1++) {
|
for (let i1 = 0; i1 < l_block15; i1++) {
|
||||||
ctx[\`category\`] = v_block15[i1];
|
ctx[\`category\`] = v_block15[i1];
|
||||||
let key1 = ctx['category'].id;
|
let key1 = ctx['category'].id;
|
||||||
let attr6 = ctx['category'].id;
|
let d13 = ctx['category'].id;
|
||||||
let attr7 = ctx['category'].id==ctx['options'].active_category_id;
|
let d14 = ctx['category'].id==ctx['options'].active_category_id;
|
||||||
let txt5 = ctx['category'].name;
|
let d15 = ctx['category'].name;
|
||||||
c_block15[i1] = withKey(block16([attr6, attr7, txt5]), key1);
|
c_block15[i1] = withKey(block16([d13, d14, d15]), key1);
|
||||||
}
|
}
|
||||||
ctx = ctx.__proto__;
|
ctx = ctx.__proto__;
|
||||||
let b15 = list(c_block15);
|
let b15 = list(c_block15);
|
||||||
b14 = block14([], [b15]);
|
b14 = block14([], [b15]);
|
||||||
}
|
}
|
||||||
let attr8 = ctx['search'].value;
|
let d16 = ctx['search'].value;
|
||||||
let hdlr4 = [ctx['updateFilter'], ctx];
|
let d17 = [ctx['updateFilter'], ctx];
|
||||||
let hdlr5 = [ctx['updateFilter'], ctx];
|
let d18 = [ctx['updateFilter'], ctx];
|
||||||
let hdlr6 = [ctx['clearSearch'], ctx];
|
let d19 = (el) => refs[\`search_input\`] = el;
|
||||||
|
let d20 = [ctx['clearSearch'], ctx];
|
||||||
|
let d21 = (el) => refs[\`settings_menu\`] = el;
|
||||||
if (ctx['triggers']) {
|
if (ctx['triggers']) {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
const [k_block18, v_block18, l_block18, c_block18] = prepareList(ctx['triggers']);
|
const [k_block18, v_block18, l_block18, c_block18] = prepareList(ctx['triggers']);
|
||||||
@@ -286,41 +286,41 @@ exports[`misc other complex template 1`] = `
|
|||||||
let key1 = ctx['trigger'].id;
|
let key1 = ctx['trigger'].id;
|
||||||
let b20;
|
let b20;
|
||||||
if (!ctx['trigger'].manual&&ctx['trigger'].project_id===ctx['project'].id&&ctx['trigger'].category_id===ctx['options'].active_category_id) {
|
if (!ctx['trigger'].manual&&ctx['trigger'].project_id===ctx['project'].id&&ctx['trigger'].category_id===ctx['options'].active_category_id) {
|
||||||
let attr9 = \`trigger_\${ctx['trigger'].id}\`;
|
let d22 = \`trigger_\${ctx['trigger'].id}\`;
|
||||||
let attr10 = \`trigger_\${ctx['trigger'].id}\`;
|
let d23 = \`trigger_\${ctx['trigger'].id}\`;
|
||||||
let attr11 = ctx['options'].trigger_display[ctx['trigger'].id];
|
let d24 = ctx['options'].trigger_display[ctx['trigger'].id];
|
||||||
let attr12 = ctx['trigger'].id;
|
let d25 = ctx['trigger'].id;
|
||||||
let hdlr7 = [ctx['updateTriggerDisplay'], ctx];
|
let d26 = [ctx['updateTriggerDisplay'], ctx];
|
||||||
let attr13 = \`trigger_\${ctx['trigger'].id}\`;
|
let d27 = \`trigger_\${ctx['trigger'].id}\`;
|
||||||
let txt6 = ctx['trigger'].name;
|
let d28 = ctx['trigger'].name;
|
||||||
b20 = block20([attr9, attr10, attr11, attr12, hdlr7, attr13, txt6]);
|
b20 = block20([d22, d23, d24, d25, d26, d27, d28]);
|
||||||
}
|
}
|
||||||
c_block18[i1] = withKey(multi([b20]), key1);
|
c_block18[i1] = withKey(multi([b20]), key1);
|
||||||
}
|
}
|
||||||
ctx = ctx.__proto__;
|
ctx = ctx.__proto__;
|
||||||
let b18 = list(c_block18);
|
let b18 = list(c_block18);
|
||||||
let hdlr8 = [ctx['triggerAll'], ctx];
|
let d29 = [ctx['triggerAll'], ctx];
|
||||||
let hdlr9 = [ctx['triggerNone'], ctx];
|
let d30 = [ctx['triggerNone'], ctx];
|
||||||
let hdlr10 = [ctx['triggerDefault'], ctx];
|
let d31 = [ctx['triggerDefault'], ctx];
|
||||||
let hdlr11 = [ctx['toggleSettingsMenu'], ctx];
|
let d32 = [ctx['toggleSettingsMenu'], ctx];
|
||||||
let b21 = block21([hdlr8, hdlr9, hdlr10, hdlr11]);
|
let b21 = block21([d29, d30, d31, d32]);
|
||||||
b17 = multi([b18, b21]);
|
b17 = multi([b18, b21]);
|
||||||
}
|
}
|
||||||
if (ctx['load_infos']) {
|
if (ctx['load_infos']) {
|
||||||
b22 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
b22 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||||
}
|
}
|
||||||
if (ctx['message']) {
|
if (ctx['message']) {
|
||||||
let txt7 = ctx['message'];
|
let d33 = ctx['message'];
|
||||||
b23 = block23([txt7]);
|
b23 = block23([d33]);
|
||||||
}
|
}
|
||||||
if (!ctx['project']) {
|
if (!ctx['project']) {
|
||||||
b24 = block24();
|
b24 = block24();
|
||||||
} else {
|
} else {
|
||||||
let b26 = component(\`BundlesList\`, {bundles: ctx['bundles'].sticky,category_custom_views: ctx['category_custom_views'],search: ctx['search']}, key + \`__2\`, node, ctx);
|
let b26 = component(\`BundlesList\`, {bundles: ctx['bundles'].sticky,category_custom_views: ctx['category_custom_views'],search: ctx['search']}, key + \`__3\`, node, ctx);
|
||||||
let b27 = component(\`BundlesList\`, {bundles: ctx['bundles'].dev,search: ctx['search']}, key + \`__3\`, node, ctx);
|
let b27 = component(\`BundlesList\`, {bundles: ctx['bundles'].dev,search: ctx['search']}, key + \`__4\`, node, ctx);
|
||||||
b25 = block25([], [b26, b27]);
|
b25 = block25([], [b26, b27]);
|
||||||
}
|
}
|
||||||
return block1([attr1, txt1, hdlr2, hdlr3, attr8, hdlr4, hdlr5, ref1, hdlr6, ref2], [b2, b4, b14, b17, b22, b23, b24, b25]);
|
return block1([d1, d2, d11, d12, d16, d17, d18, d19, d20, d21], [b2, b4, b14, b17, b22, b23, b24, b25]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
exports[`memory t-foreach does not leak stuff in global scope 1`] = `
|
exports[`memory t-foreach does not leak stuff in global scope 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<p><block-child-0/></p>\`);
|
let block1 = createBlock(\`<p><block-child-0/></p>\`);
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
exports[`simple templates, mostly static can render a table row 1`] = `
|
exports[`simple templates, mostly static can render a table row 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<tr><td>cell</td></tr>\`);
|
let block1 = createBlock(\`<tr><td>cell</td></tr>\`);
|
||||||
|
|
||||||
@@ -16,7 +17,8 @@ exports[`simple templates, mostly static can render a table row 1`] = `
|
|||||||
exports[`simple templates, mostly static div with a class attribute 1`] = `
|
exports[`simple templates, mostly static div with a class attribute 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div class=\\"abc\\">foo</div>\`);
|
let block1 = createBlock(\`<div class=\\"abc\\">foo</div>\`);
|
||||||
|
|
||||||
@@ -29,7 +31,8 @@ exports[`simple templates, mostly static div with a class attribute 1`] = `
|
|||||||
exports[`simple templates, mostly static div with a class attribute with a quote 1`] = `
|
exports[`simple templates, mostly static div with a class attribute with a quote 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div class=\\"a'bc\\">word</div>\`);
|
let block1 = createBlock(\`<div class=\\"a'bc\\">word</div>\`);
|
||||||
|
|
||||||
@@ -42,7 +45,8 @@ exports[`simple templates, mostly static div with a class attribute with a quote
|
|||||||
exports[`simple templates, mostly static div with a span child node 1`] = `
|
exports[`simple templates, mostly static div with a span child node 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><span>word</span></div>\`);
|
let block1 = createBlock(\`<div><span>word</span></div>\`);
|
||||||
|
|
||||||
@@ -55,7 +59,8 @@ exports[`simple templates, mostly static div with a span child node 1`] = `
|
|||||||
exports[`simple templates, mostly static div with an arbitrary attribute with a quote 1`] = `
|
exports[`simple templates, mostly static div with an arbitrary attribute with a quote 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div abc=\\"a'bc\\">word</div>\`);
|
let block1 = createBlock(\`<div abc=\\"a'bc\\">word</div>\`);
|
||||||
|
|
||||||
@@ -68,7 +73,8 @@ exports[`simple templates, mostly static div with an arbitrary attribute with a
|
|||||||
exports[`simple templates, mostly static div with an empty class attribute 1`] = `
|
exports[`simple templates, mostly static div with an empty class attribute 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>word</div>\`);
|
let block1 = createBlock(\`<div>word</div>\`);
|
||||||
|
|
||||||
@@ -81,7 +87,8 @@ exports[`simple templates, mostly static div with an empty class attribute 1`] =
|
|||||||
exports[`simple templates, mostly static div with content 1`] = `
|
exports[`simple templates, mostly static div with content 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>foo</div>\`);
|
let block1 = createBlock(\`<div>foo</div>\`);
|
||||||
|
|
||||||
@@ -94,13 +101,14 @@ exports[`simple templates, mostly static div with content 1`] = `
|
|||||||
exports[`simple templates, mostly static dom node with t-esc 1`] = `
|
exports[`simple templates, mostly static dom node with t-esc 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['text'];
|
let d1 = ctx['text'];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -108,13 +116,14 @@ exports[`simple templates, mostly static dom node with t-esc 1`] = `
|
|||||||
exports[`simple templates, mostly static dom node with t-esc 2`] = `
|
exports[`simple templates, mostly static dom node with t-esc 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['text'];
|
let d1 = ctx['text'];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -122,7 +131,8 @@ exports[`simple templates, mostly static dom node with t-esc 2`] = `
|
|||||||
exports[`simple templates, mostly static dynamic text value 1`] = `
|
exports[`simple templates, mostly static dynamic text value 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return text(ctx['text']);
|
return text(ctx['text']);
|
||||||
@@ -133,7 +143,8 @@ exports[`simple templates, mostly static dynamic text value 1`] = `
|
|||||||
exports[`simple templates, mostly static empty div 1`] = `
|
exports[`simple templates, mostly static empty div 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
@@ -146,7 +157,8 @@ exports[`simple templates, mostly static empty div 1`] = `
|
|||||||
exports[`simple templates, mostly static empty string 1`] = `
|
exports[`simple templates, mostly static empty string 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return text(\`\`);
|
return text(\`\`);
|
||||||
@@ -157,7 +169,8 @@ exports[`simple templates, mostly static empty string 1`] = `
|
|||||||
exports[`simple templates, mostly static empty string in a template set 1`] = `
|
exports[`simple templates, mostly static empty string in a template set 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return text(\`\`);
|
return text(\`\`);
|
||||||
@@ -168,7 +181,8 @@ exports[`simple templates, mostly static empty string in a template set 1`] = `
|
|||||||
exports[`simple templates, mostly static inline template string in t-esc 1`] = `
|
exports[`simple templates, mostly static inline template string in t-esc 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return text(\`text\`);
|
return text(\`text\`);
|
||||||
@@ -179,8 +193,8 @@ exports[`simple templates, mostly static inline template string in t-esc 1`] = `
|
|||||||
exports[`simple templates, mostly static inline template string with content in t-esc 1`] = `
|
exports[`simple templates, mostly static inline template string with content in t-esc 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
@@ -194,7 +208,8 @@ exports[`simple templates, mostly static inline template string with content in
|
|||||||
exports[`simple templates, mostly static inline template string with variable in context 1`] = `
|
exports[`simple templates, mostly static inline template string with variable in context 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return text(\`text \${ctx['v']}\`);
|
return text(\`text \${ctx['v']}\`);
|
||||||
@@ -205,7 +220,8 @@ exports[`simple templates, mostly static inline template string with variable in
|
|||||||
exports[`simple templates, mostly static multiple root nodes 1`] = `
|
exports[`simple templates, mostly static multiple root nodes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block2 = createBlock(\`<div>foo</div>\`);
|
let block2 = createBlock(\`<div>foo</div>\`);
|
||||||
let block3 = createBlock(\`<span>hey</span>\`);
|
let block3 = createBlock(\`<span>hey</span>\`);
|
||||||
@@ -221,7 +237,8 @@ exports[`simple templates, mostly static multiple root nodes 1`] = `
|
|||||||
exports[`simple templates, mostly static simple string 1`] = `
|
exports[`simple templates, mostly static simple string 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return text(\`hello vdom\`);
|
return text(\`hello vdom\`);
|
||||||
@@ -232,7 +249,8 @@ exports[`simple templates, mostly static simple string 1`] = `
|
|||||||
exports[`simple templates, mostly static simple string in t tag 1`] = `
|
exports[`simple templates, mostly static simple string in t tag 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return text(\`hello vdom\`);
|
return text(\`hello vdom\`);
|
||||||
@@ -243,7 +261,8 @@ exports[`simple templates, mostly static simple string in t tag 1`] = `
|
|||||||
exports[`simple templates, mostly static static text and dynamic text (no t tag) 1`] = `
|
exports[`simple templates, mostly static static text and dynamic text (no t tag) 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = text(\`hello \`);
|
let b2 = text(\`hello \`);
|
||||||
@@ -256,7 +275,8 @@ exports[`simple templates, mostly static static text and dynamic text (no t tag)
|
|||||||
exports[`simple templates, mostly static static text and dynamic text 1`] = `
|
exports[`simple templates, mostly static static text and dynamic text 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = text(\`hello \`);
|
let b2 = text(\`hello \`);
|
||||||
@@ -269,13 +289,14 @@ exports[`simple templates, mostly static static text and dynamic text 1`] = `
|
|||||||
exports[`simple templates, mostly static t-esc in dom node 1`] = `
|
exports[`simple templates, mostly static t-esc in dom node 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['text'];
|
let d1 = ctx['text'];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -283,13 +304,14 @@ exports[`simple templates, mostly static t-esc in dom node 1`] = `
|
|||||||
exports[`simple templates, mostly static t-esc in dom node, variations 1`] = `
|
exports[`simple templates, mostly static t-esc in dom node, variations 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>hello <block-text-0/></div>\`);
|
let block1 = createBlock(\`<div>hello <block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['text'];
|
let d1 = ctx['text'];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -297,46 +319,14 @@ exports[`simple templates, mostly static t-esc in dom node, variations 1`] = `
|
|||||||
exports[`simple templates, mostly static t-esc in dom node, variations 2`] = `
|
exports[`simple templates, mostly static t-esc in dom node, variations 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>hello <block-text-0/> world</div>\`);
|
let block1 = createBlock(\`<div>hello <block-text-0/> world</div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['text'];
|
let d1 = ctx['text'];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`simple templates, mostly static template with multiple t tag with multiple content 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/><block-text-1/>Loading<block-text-2/></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['a'];
|
|
||||||
let txt2 = ctx['b'];
|
|
||||||
let txt3 = ctx['c'];
|
|
||||||
return block1([txt1, txt2, txt3]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`simple templates, mostly static template with t tag with multiple content 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>Loading<block-child-0/></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let b2;
|
|
||||||
if (false) {
|
|
||||||
b2 = text(\`\`);
|
|
||||||
}
|
|
||||||
return block1([], [b2]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -344,7 +334,8 @@ exports[`simple templates, mostly static template with t tag with multiple conte
|
|||||||
exports[`simple templates, mostly static two t-escs next to each other 1`] = `
|
exports[`simple templates, mostly static two t-escs next to each other 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = text(ctx['text1']);
|
let b2 = text(ctx['text1']);
|
||||||
@@ -357,7 +348,8 @@ exports[`simple templates, mostly static two t-escs next to each other 1`] = `
|
|||||||
exports[`simple templates, mostly static two t-escs next to each other 2`] = `
|
exports[`simple templates, mostly static two t-escs next to each other 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = text(ctx['text1']);
|
let b2 = text(ctx['text1']);
|
||||||
@@ -370,14 +362,15 @@ exports[`simple templates, mostly static two t-escs next to each other 2`] = `
|
|||||||
exports[`simple templates, mostly static two t-escs next to each other, in a div 1`] = `
|
exports[`simple templates, mostly static two t-escs next to each other, in a div 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['text1'];
|
let d1 = ctx['text1'];
|
||||||
let txt2 = ctx['text2'];
|
let d2 = ctx['text2'];
|
||||||
return block1([txt1, txt2]);
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
exports[`properly support svg add proper namespace to g tags 1`] = `
|
exports[`properly support svg add proper namespace to g tags 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<g block-ns=\\"http://www.w3.org/2000/svg\\"><circle cx=\\"50\\" cy=\\"50\\" r=\\"4\\" stroke=\\"green\\" stroke-width=\\"1\\" fill=\\"yellow\\"/> </g>\`);
|
let block1 = createBlock(\`<g block-ns=\\"http://www.w3.org/2000/svg\\"><circle cx=\\"50\\" cy=\\"50\\" r=\\"4\\" stroke=\\"green\\" stroke-width=\\"1\\" fill=\\"yellow\\"/> </g>\`);
|
||||||
|
|
||||||
@@ -16,7 +17,8 @@ exports[`properly support svg add proper namespace to g tags 1`] = `
|
|||||||
exports[`properly support svg add proper namespace to svg 1`] = `
|
exports[`properly support svg add proper namespace to svg 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<svg block-ns=\\"http://www.w3.org/2000/svg\\" width=\\"100px\\" height=\\"90px\\"><circle cx=\\"50\\" cy=\\"50\\" r=\\"4\\" stroke=\\"green\\" stroke-width=\\"1\\" fill=\\"yellow\\"/> </svg>\`);
|
let block1 = createBlock(\`<svg block-ns=\\"http://www.w3.org/2000/svg\\" width=\\"100px\\" height=\\"90px\\"><circle cx=\\"50\\" cy=\\"50\\" r=\\"4\\" stroke=\\"green\\" stroke-width=\\"1\\" fill=\\"yellow\\"/> </svg>\`);
|
||||||
|
|
||||||
@@ -29,7 +31,8 @@ exports[`properly support svg add proper namespace to svg 1`] = `
|
|||||||
exports[`properly support svg namespace to g tags not added if already in svg namespace 1`] = `
|
exports[`properly support svg namespace to g tags not added if already in svg namespace 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<svg block-ns=\\"http://www.w3.org/2000/svg\\"><g/></svg>\`);
|
let block1 = createBlock(\`<svg block-ns=\\"http://www.w3.org/2000/svg\\"><g/></svg>\`);
|
||||||
|
|
||||||
@@ -42,7 +45,8 @@ exports[`properly support svg namespace to g tags not added if already in svg na
|
|||||||
exports[`properly support svg namespace to svg tags added even if already in svg namespace 1`] = `
|
exports[`properly support svg namespace to svg tags added even if already in svg namespace 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<svg block-ns=\\"http://www.w3.org/2000/svg\\"><svg block-ns=\\"http://www.w3.org/2000/svg\\"/></svg>\`);
|
let block1 = createBlock(\`<svg block-ns=\\"http://www.w3.org/2000/svg\\"><svg block-ns=\\"http://www.w3.org/2000/svg\\"/></svg>\`);
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,8 @@
|
|||||||
exports[`debugging t-debug 1`] = `
|
exports[`debugging t-debug 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block2 = createBlock(\`<span>hey</span>\`);
|
let block2 = createBlock(\`<span>hey</span>\`);
|
||||||
@@ -23,7 +24,8 @@ exports[`debugging t-debug 1`] = `
|
|||||||
exports[`debugging t-debug on sub template 1`] = `
|
exports[`debugging t-debug on sub template 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<p>coucou</p>\`);
|
let block1 = createBlock(\`<p>coucou</p>\`);
|
||||||
|
|
||||||
@@ -37,14 +39,14 @@ exports[`debugging t-debug on sub template 1`] = `
|
|||||||
exports[`debugging t-debug on sub template 2`] = `
|
exports[`debugging t-debug on sub template 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { getTemplate } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`sub\`);
|
const callTemplate_2 = getTemplate(\`sub\`);
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
let b2 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
@@ -53,8 +55,8 @@ exports[`debugging t-debug on sub template 2`] = `
|
|||||||
exports[`debugging t-log 1`] = `
|
exports[`debugging t-log 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
|
|||||||
@@ -3,17 +3,18 @@
|
|||||||
exports[`t-esc div with falsy values 1`] = `
|
exports[`t-esc div with falsy values 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><p><block-text-0/></p><p><block-text-1/></p><p><block-text-2/></p><p><block-text-3/></p><p><block-text-4/></p></div>\`);
|
let block1 = createBlock(\`<div><p><block-text-0/></p><p><block-text-1/></p><p><block-text-2/></p><p><block-text-3/></p><p><block-text-4/></p></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['v1'];
|
let d1 = ctx['v1'];
|
||||||
let txt2 = ctx['v2'];
|
let d2 = ctx['v2'];
|
||||||
let txt3 = ctx['v3'];
|
let d3 = ctx['v3'];
|
||||||
let txt4 = ctx['v4'];
|
let d4 = ctx['v4'];
|
||||||
let txt5 = ctx['v5'];
|
let d5 = ctx['v5'];
|
||||||
return block1([txt1, txt2, txt3, txt4, txt5]);
|
return block1([d1, d2, d3, d4, d5]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -21,13 +22,14 @@ exports[`t-esc div with falsy values 1`] = `
|
|||||||
exports[`t-esc escaping 1`] = `
|
exports[`t-esc escaping 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['var'];
|
let d1 = ctx['var'];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -35,13 +37,14 @@ exports[`t-esc escaping 1`] = `
|
|||||||
exports[`t-esc escaping on a node 1`] = `
|
exports[`t-esc escaping on a node 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = 'ok';
|
let d1 = 'ok';
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -49,14 +52,14 @@ exports[`t-esc escaping on a node 1`] = `
|
|||||||
exports[`t-esc escaping on a node with a body 1`] = `
|
exports[`t-esc escaping on a node with a body 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { withDefault } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = withDefault('ok', \`nope\`);
|
let d1 = withDefault('ok', \`nope\`);
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -64,14 +67,14 @@ exports[`t-esc escaping on a node with a body 1`] = `
|
|||||||
exports[`t-esc escaping on a node with a body, as a default 1`] = `
|
exports[`t-esc escaping on a node with a body, as a default 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { withDefault } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = withDefault(ctx['var'], \`nope\`);
|
let d1 = withDefault(ctx['var'], \`nope\`);
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -79,7 +82,8 @@ exports[`t-esc escaping on a node with a body, as a default 1`] = `
|
|||||||
exports[`t-esc falsy values in text nodes 1`] = `
|
exports[`t-esc falsy values in text nodes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = text(ctx['v1']);
|
let b2 = text(ctx['v1']);
|
||||||
@@ -99,13 +103,14 @@ exports[`t-esc falsy values in text nodes 1`] = `
|
|||||||
exports[`t-esc literal 1`] = `
|
exports[`t-esc literal 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = 'ok';
|
let d1 = 'ok';
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -113,22 +118,19 @@ exports[`t-esc literal 1`] = `
|
|||||||
exports[`t-esc t-esc is escaped 1`] = `
|
exports[`t-esc t-esc is escaped 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, LazyValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
let block2 = createBlock(\`<p>escaped</p>\`);
|
let block2 = createBlock(\`<p>escaped</p>\`);
|
||||||
|
|
||||||
function value1(ctx, node, key = \\"\\") {
|
|
||||||
return block2();
|
|
||||||
}
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
ctx[\`var\`] = new LazyValue(value1, ctx, node);
|
let b2 = block2();
|
||||||
let txt1 = ctx['var'];
|
ctx[\`var\`] = b2;
|
||||||
return block1([txt1]);
|
let d1 = ctx['var'];
|
||||||
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -136,13 +138,14 @@ exports[`t-esc t-esc is escaped 1`] = `
|
|||||||
exports[`t-esc t-esc work with spread operator 1`] = `
|
exports[`t-esc t-esc work with spread operator 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = [...ctx['state'].list];
|
let d1 = [...ctx['state'].list];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -150,9 +153,24 @@ exports[`t-esc t-esc work with spread operator 1`] = `
|
|||||||
exports[`t-esc t-esc=0 is escaped 1`] = `
|
exports[`t-esc t-esc=0 is escaped 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, zero, getTemplate } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`sub\`);
|
|
||||||
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx[zero];
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`t-esc t-esc=0 is escaped 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
const callTemplate_2 = getTemplate(\`sub\`);
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block2 = createBlock(\`<p>escaped</p>\`);
|
let block2 = createBlock(\`<p>escaped</p>\`);
|
||||||
@@ -162,37 +180,23 @@ exports[`t-esc t-esc=0 is escaped 1`] = `
|
|||||||
ctx[isBoundary] = 1;
|
ctx[isBoundary] = 1;
|
||||||
let b2 = block2();
|
let b2 = block2();
|
||||||
ctx[zero] = b2;
|
ctx[zero] = b2;
|
||||||
let b3 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
let b3 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||||
return block1([], [b3]);
|
return block1([], [b3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-esc t-esc=0 is escaped 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { zero } = helpers;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx[zero];
|
|
||||||
return block1([txt1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-esc variable 1`] = `
|
exports[`t-esc variable 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['var'];
|
let d1 = ctx['var'];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
exports[`t-foreach does not pollute the rendering context 1`] = `
|
exports[`t-foreach does not pollute the rendering context 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -25,8 +25,8 @@ exports[`t-foreach does not pollute the rendering context 1`] = `
|
|||||||
exports[`t-foreach iterate on items (on a element node) 1`] = `
|
exports[`t-foreach iterate on items (on a element node) 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block3 = createBlock(\`<span><block-text-0/></span>\`);
|
let block3 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
@@ -37,8 +37,8 @@ exports[`t-foreach iterate on items (on a element node) 1`] = `
|
|||||||
for (let i1 = 0; i1 < l_block2; i1++) {
|
for (let i1 = 0; i1 < l_block2; i1++) {
|
||||||
ctx[\`item\`] = v_block2[i1];
|
ctx[\`item\`] = v_block2[i1];
|
||||||
let key1 = ctx['item'];
|
let key1 = ctx['item'];
|
||||||
let txt1 = ctx['item'];
|
let d1 = ctx['item'];
|
||||||
c_block2[i1] = withKey(block3([txt1]), key1);
|
c_block2[i1] = withKey(block3([d1]), key1);
|
||||||
}
|
}
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
@@ -49,8 +49,8 @@ exports[`t-foreach iterate on items (on a element node) 1`] = `
|
|||||||
exports[`t-foreach iterate on items 1`] = `
|
exports[`t-foreach iterate on items 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -80,8 +80,8 @@ exports[`t-foreach iterate on items 1`] = `
|
|||||||
exports[`t-foreach iterate, dict param 1`] = `
|
exports[`t-foreach iterate, dict param 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -111,8 +111,8 @@ exports[`t-foreach iterate, dict param 1`] = `
|
|||||||
exports[`t-foreach iterate, position 1`] = `
|
exports[`t-foreach iterate, position 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -147,8 +147,8 @@ exports[`t-foreach iterate, position 1`] = `
|
|||||||
exports[`t-foreach simple iteration (in a node) 1`] = `
|
exports[`t-foreach simple iteration (in a node) 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -169,8 +169,8 @@ exports[`t-foreach simple iteration (in a node) 1`] = `
|
|||||||
exports[`t-foreach simple iteration 1`] = `
|
exports[`t-foreach simple iteration 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
@@ -188,8 +188,8 @@ exports[`t-foreach simple iteration 1`] = `
|
|||||||
exports[`t-foreach simple iteration with two nodes inside 1`] = `
|
exports[`t-foreach simple iteration with two nodes inside 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block3 = createBlock(\`<span>a<block-text-0/></span>\`);
|
let block3 = createBlock(\`<span>a<block-text-0/></span>\`);
|
||||||
let block4 = createBlock(\`<span>b<block-text-0/></span>\`);
|
let block4 = createBlock(\`<span>b<block-text-0/></span>\`);
|
||||||
@@ -200,10 +200,10 @@ exports[`t-foreach simple iteration with two nodes inside 1`] = `
|
|||||||
for (let i1 = 0; i1 < l_block1; i1++) {
|
for (let i1 = 0; i1 < l_block1; i1++) {
|
||||||
ctx[\`item\`] = v_block1[i1];
|
ctx[\`item\`] = v_block1[i1];
|
||||||
let key1 = ctx['item'];
|
let key1 = ctx['item'];
|
||||||
let txt1 = ctx['item'];
|
let d1 = ctx['item'];
|
||||||
let b3 = block3([txt1]);
|
let b3 = block3([d1]);
|
||||||
let txt2 = ctx['item'];
|
let d2 = ctx['item'];
|
||||||
let b4 = block4([txt2]);
|
let b4 = block4([d2]);
|
||||||
c_block1[i1] = withKey(multi([b3, b4]), key1);
|
c_block1[i1] = withKey(multi([b3, b4]), key1);
|
||||||
}
|
}
|
||||||
return list(c_block1);
|
return list(c_block1);
|
||||||
@@ -214,9 +214,28 @@ exports[`t-foreach simple iteration with two nodes inside 1`] = `
|
|||||||
exports[`t-foreach t-call with body in t-foreach in t-foreach 1`] = `
|
exports[`t-foreach t-call with body in t-foreach in t-foreach 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, isBoundary, withDefault, setContextValue, getTemplate, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`sub\`);
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let b2 = text(\` [\`);
|
||||||
|
let b3 = text(ctx['a']);
|
||||||
|
let b4 = text(\`] [\`);
|
||||||
|
let b5 = text(ctx['b']);
|
||||||
|
let b6 = text(\`] [\`);
|
||||||
|
let b7 = text(ctx['c']);
|
||||||
|
let b8 = text(\`] \`);
|
||||||
|
return multi([b2, b3, b4, b5, b6, b7, b8]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`t-foreach t-call with body in t-foreach in t-foreach 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
const callTemplate_2 = getTemplate(\`sub\`);
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><span>[<block-text-0/>][<block-text-1/>][<block-text-2/>]</span></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><span>[<block-text-0/>][<block-text-1/>][<block-text-2/>]</span></div>\`);
|
||||||
let block6 = createBlock(\`<span><block-text-0/></span>\`);
|
let block6 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
@@ -245,31 +264,35 @@ exports[`t-foreach t-call with body in t-foreach in t-foreach 1`] = `
|
|||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1;
|
ctx[isBoundary] = 1;
|
||||||
setContextValue(ctx, \\"c\\", 'x'+'_'+ctx['a']+'_'+ctx['b']);
|
setContextValue(ctx, \\"c\\", 'x'+'_'+ctx['a']+'_'+ctx['b']);
|
||||||
c_block4[i2] = withKey(callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}__\${key2}\`), key2);
|
c_block4[i2] = withKey(callTemplate_2.call(this, ctx, node, key + \`__1__\${key1}__\${key2}\`), key2);
|
||||||
ctx = ctx.__proto__;
|
ctx = ctx.__proto__;
|
||||||
}
|
}
|
||||||
ctx = ctx.__proto__;
|
ctx = ctx.__proto__;
|
||||||
let b4 = list(c_block4);
|
let b4 = list(c_block4);
|
||||||
let txt1 = ctx['c'];
|
let d1 = ctx['c'];
|
||||||
let b6 = block6([txt1]);
|
let b6 = block6([d1]);
|
||||||
c_block2[i1] = withKey(multi([b4, b6]), key1);
|
c_block2[i1] = withKey(multi([b4, b6]), key1);
|
||||||
}
|
}
|
||||||
ctx = ctx.__proto__;
|
ctx = ctx.__proto__;
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
let txt2 = ctx['a'];
|
let d2 = ctx['a'];
|
||||||
let txt3 = ctx['b'];
|
let d3 = ctx['b'];
|
||||||
let txt4 = ctx['c'];
|
let d4 = ctx['c'];
|
||||||
return block1([txt2, txt3, txt4], [b2]);
|
return block1([d2, d3, d4], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-foreach t-call with body in t-foreach in t-foreach 2`] = `
|
exports[`t-foreach t-call without body in t-foreach in t-foreach 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
ctx = Object.create(ctx);
|
||||||
|
ctx[isBoundary] = 1
|
||||||
|
setContextValue(ctx, \\"c\\", 'x'+'_'+ctx['a']+'_'+ctx['b']);
|
||||||
let b2 = text(\` [\`);
|
let b2 = text(\` [\`);
|
||||||
let b3 = text(ctx['a']);
|
let b3 = text(ctx['a']);
|
||||||
let b4 = text(\`] [\`);
|
let b4 = text(\`] [\`);
|
||||||
@@ -282,12 +305,12 @@ exports[`t-foreach t-call with body in t-foreach in t-foreach 2`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-foreach t-call without body in t-foreach in t-foreach 1`] = `
|
exports[`t-foreach t-call without body in t-foreach in t-foreach 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, getTemplate, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`sub\`);
|
const callTemplate_2 = getTemplate(\`sub\`);
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><span>[<block-text-0/>][<block-text-1/>][<block-text-2/>]</span></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><span>[<block-text-0/>][<block-text-1/>][<block-text-2/>]</span></div>\`);
|
||||||
let block6 = createBlock(\`<span><block-text-0/></span>\`);
|
let block6 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
@@ -311,42 +334,20 @@ exports[`t-foreach t-call without body in t-foreach in t-foreach 1`] = `
|
|||||||
ctx[\`b_index\`] = i2;
|
ctx[\`b_index\`] = i2;
|
||||||
ctx[\`b_value\`] = k_block4[i2];
|
ctx[\`b_value\`] = k_block4[i2];
|
||||||
let key2 = ctx['b'];
|
let key2 = ctx['b'];
|
||||||
c_block4[i2] = withKey(callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}__\${key2}\`), key2);
|
c_block4[i2] = withKey(callTemplate_2.call(this, ctx, node, key + \`__1__\${key1}__\${key2}\`), key2);
|
||||||
}
|
}
|
||||||
ctx = ctx.__proto__;
|
ctx = ctx.__proto__;
|
||||||
let b4 = list(c_block4);
|
let b4 = list(c_block4);
|
||||||
let txt1 = ctx['c'];
|
let d1 = ctx['c'];
|
||||||
let b6 = block6([txt1]);
|
let b6 = block6([d1]);
|
||||||
c_block2[i1] = withKey(multi([b4, b6]), key1);
|
c_block2[i1] = withKey(multi([b4, b6]), key1);
|
||||||
}
|
}
|
||||||
ctx = ctx.__proto__;
|
ctx = ctx.__proto__;
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
let txt2 = ctx['a'];
|
let d2 = ctx['a'];
|
||||||
let txt3 = ctx['b'];
|
let d3 = ctx['b'];
|
||||||
let txt4 = ctx['c'];
|
let d4 = ctx['c'];
|
||||||
return block1([txt2, txt3, txt4], [b2]);
|
return block1([d2, d3, d4], [b2]);
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-foreach t-call without body in t-foreach in t-foreach 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
ctx = Object.create(ctx);
|
|
||||||
ctx[isBoundary] = 1
|
|
||||||
setContextValue(ctx, \\"c\\", 'x'+'_'+ctx['a']+'_'+ctx['b']);
|
|
||||||
let b2 = text(\` [\`);
|
|
||||||
let b3 = text(ctx['a']);
|
|
||||||
let b4 = text(\`] [\`);
|
|
||||||
let b5 = text(ctx['b']);
|
|
||||||
let b6 = text(\`] [\`);
|
|
||||||
let b7 = text(ctx['c']);
|
|
||||||
let b8 = text(\`] \`);
|
|
||||||
return multi([b2, b3, b4, b5, b6, b7, b8]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -354,8 +355,8 @@ exports[`t-foreach t-call without body in t-foreach in t-foreach 2`] = `
|
|||||||
exports[`t-foreach t-foreach in t-foreach 1`] = `
|
exports[`t-foreach t-foreach in t-foreach 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -388,8 +389,8 @@ exports[`t-foreach t-foreach in t-foreach 1`] = `
|
|||||||
exports[`t-foreach t-foreach with t-if inside (no external node) 1`] = `
|
exports[`t-foreach t-foreach with t-if inside (no external node) 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block3 = createBlock(\`<span><block-text-0/></span>\`);
|
let block3 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
@@ -401,8 +402,8 @@ exports[`t-foreach t-foreach with t-if inside (no external node) 1`] = `
|
|||||||
let key1 = ctx['elem'].id;
|
let key1 = ctx['elem'].id;
|
||||||
let b3;
|
let b3;
|
||||||
if (ctx['elem'].id<3) {
|
if (ctx['elem'].id<3) {
|
||||||
let txt1 = ctx['elem'].text;
|
let d1 = ctx['elem'].text;
|
||||||
b3 = block3([txt1]);
|
b3 = block3([d1]);
|
||||||
}
|
}
|
||||||
c_block1[i1] = withKey(multi([b3]), key1);
|
c_block1[i1] = withKey(multi([b3]), key1);
|
||||||
}
|
}
|
||||||
@@ -414,8 +415,8 @@ exports[`t-foreach t-foreach with t-if inside (no external node) 1`] = `
|
|||||||
exports[`t-foreach t-foreach with t-if inside 1`] = `
|
exports[`t-foreach t-foreach with t-if inside 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block4 = createBlock(\`<span><block-text-0/></span>\`);
|
let block4 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
@@ -428,8 +429,8 @@ exports[`t-foreach t-foreach with t-if inside 1`] = `
|
|||||||
let key1 = ctx['elem'].id;
|
let key1 = ctx['elem'].id;
|
||||||
let b4;
|
let b4;
|
||||||
if (ctx['elem'].id<3) {
|
if (ctx['elem'].id<3) {
|
||||||
let txt1 = ctx['elem'].text;
|
let d1 = ctx['elem'].text;
|
||||||
b4 = block4([txt1]);
|
b4 = block4([d1]);
|
||||||
}
|
}
|
||||||
c_block2[i1] = withKey(multi([b4]), key1);
|
c_block2[i1] = withKey(multi([b4]), key1);
|
||||||
}
|
}
|
||||||
@@ -442,8 +443,8 @@ exports[`t-foreach t-foreach with t-if inside 1`] = `
|
|||||||
exports[`t-foreach t-key on t-foreach 1`] = `
|
exports[`t-foreach t-key on t-foreach 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block3 = createBlock(\`<span/>\`);
|
let block3 = createBlock(\`<span/>\`);
|
||||||
@@ -465,8 +466,8 @@ exports[`t-foreach t-key on t-foreach 1`] = `
|
|||||||
exports[`t-foreach throws error if invalid loop expression 1`] = `
|
exports[`t-foreach throws error if invalid loop expression 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block3 = createBlock(\`<span/>\`);
|
let block3 = createBlock(\`<span/>\`);
|
||||||
@@ -490,8 +491,9 @@ exports[`t-foreach throws error if invalid loop expression 1`] = `
|
|||||||
exports[`t-foreach with t-memo 1`] = `
|
exports[`t-foreach with t-memo 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
let assign = Object.assign;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block3 = createBlock(\`<p><block-text-0/><block-text-1/></p>\`);
|
let block3 = createBlock(\`<p><block-text-0/><block-text-1/></p>\`);
|
||||||
@@ -513,10 +515,10 @@ exports[`t-foreach with t-memo 1`] = `
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let txt1 = ctx['item'].x;
|
let d1 = ctx['item'].x;
|
||||||
let txt2 = ctx['item'].y;
|
let d2 = ctx['item'].y;
|
||||||
c_block2[i1] = withKey(block3([txt1, txt2]), key1);
|
c_block2[i1] = withKey(block3([d1, d2]), key1);
|
||||||
nextCache[key1] = Object.assign(c_block2[i1], {memo: memo1});
|
nextCache[key1] = assign(c_block2[i1], {memo: memo1});
|
||||||
}
|
}
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
exports[`t-if a t-if next to a div 1`] = `
|
exports[`t-if a t-if next to a div 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block2 = createBlock(\`<div>foo</div>\`);
|
let block2 = createBlock(\`<div>foo</div>\`);
|
||||||
|
|
||||||
@@ -21,7 +22,8 @@ exports[`t-if a t-if next to a div 1`] = `
|
|||||||
exports[`t-if a t-if with two inner nodes 1`] = `
|
exports[`t-if a t-if with two inner nodes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block3 = createBlock(\`<span>yip</span>\`);
|
let block3 = createBlock(\`<span>yip</span>\`);
|
||||||
let block4 = createBlock(\`<div>yip</div>\`);
|
let block4 = createBlock(\`<div>yip</div>\`);
|
||||||
@@ -41,7 +43,8 @@ exports[`t-if a t-if with two inner nodes 1`] = `
|
|||||||
exports[`t-if boolean value condition elif (no outside node) 1`] = `
|
exports[`t-if boolean value condition elif (no outside node) 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2,b3,b4,b5;
|
let b2,b3,b4,b5;
|
||||||
@@ -62,7 +65,8 @@ exports[`t-if boolean value condition elif (no outside node) 1`] = `
|
|||||||
exports[`t-if boolean value condition elif 1`] = `
|
exports[`t-if boolean value condition elif 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-2/><block-child-3/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-2/><block-child-3/></div>\`);
|
||||||
|
|
||||||
@@ -85,7 +89,8 @@ exports[`t-if boolean value condition elif 1`] = `
|
|||||||
exports[`t-if boolean value condition else 1`] = `
|
exports[`t-if boolean value condition else 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><span>begin</span><block-child-0/><block-child-1/><span>end</span></div>\`);
|
let block1 = createBlock(\`<div><span>begin</span><block-child-0/><block-child-1/><span>end</span></div>\`);
|
||||||
|
|
||||||
@@ -104,7 +109,8 @@ exports[`t-if boolean value condition else 1`] = `
|
|||||||
exports[`t-if boolean value condition false else 1`] = `
|
exports[`t-if boolean value condition false else 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><span>begin</span><block-child-0/><block-child-1/><span>end</span></div>\`);
|
let block1 = createBlock(\`<div><span>begin</span><block-child-0/><block-child-1/><span>end</span></div>\`);
|
||||||
|
|
||||||
@@ -123,7 +129,8 @@ exports[`t-if boolean value condition false else 1`] = `
|
|||||||
exports[`t-if boolean value condition missing 1`] = `
|
exports[`t-if boolean value condition missing 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
|
|
||||||
@@ -140,7 +147,8 @@ exports[`t-if boolean value condition missing 1`] = `
|
|||||||
exports[`t-if can use some boolean operators in expressions 1`] = `
|
exports[`t-if can use some boolean operators in expressions 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-2/><block-child-3/><block-child-4/><block-child-5/><block-child-6/><block-child-7/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/><block-child-2/><block-child-3/><block-child-4/><block-child-5/><block-child-6/><block-child-7/></div>\`);
|
||||||
|
|
||||||
@@ -178,7 +186,8 @@ exports[`t-if can use some boolean operators in expressions 1`] = `
|
|||||||
exports[`t-if div containing a t-if with two inner nodes 1`] = `
|
exports[`t-if div containing a t-if with two inner nodes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block3 = createBlock(\`<span>yip</span>\`);
|
let block3 = createBlock(\`<span>yip</span>\`);
|
||||||
@@ -199,7 +208,8 @@ exports[`t-if div containing a t-if with two inner nodes 1`] = `
|
|||||||
exports[`t-if dynamic content after t-if with two children nodes 1`] = `
|
exports[`t-if dynamic content after t-if with two children nodes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`);
|
||||||
let block3 = createBlock(\`<p>1</p>\`);
|
let block3 = createBlock(\`<p>1</p>\`);
|
||||||
@@ -212,8 +222,8 @@ exports[`t-if dynamic content after t-if with two children nodes 1`] = `
|
|||||||
let b4 = block4();
|
let b4 = block4();
|
||||||
b2 = multi([b3, b4]);
|
b2 = multi([b3, b4]);
|
||||||
}
|
}
|
||||||
let txt1 = ctx['text'];
|
let d1 = ctx['text'];
|
||||||
return block1([txt1], [b2]);
|
return block1([d1], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -221,7 +231,8 @@ exports[`t-if dynamic content after t-if with two children nodes 1`] = `
|
|||||||
exports[`t-if just a t-if 1`] = `
|
exports[`t-if just a t-if 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2;
|
let b2;
|
||||||
@@ -236,7 +247,8 @@ exports[`t-if just a t-if 1`] = `
|
|||||||
exports[`t-if simple t-if/t-else 1`] = `
|
exports[`t-if simple t-if/t-else 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2,b3;
|
let b2,b3;
|
||||||
@@ -253,7 +265,8 @@ exports[`t-if simple t-if/t-else 1`] = `
|
|||||||
exports[`t-if simple t-if/t-else in a div 1`] = `
|
exports[`t-if simple t-if/t-else in a div 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
||||||
|
|
||||||
@@ -272,7 +285,8 @@ exports[`t-if simple t-if/t-else in a div 1`] = `
|
|||||||
exports[`t-if t-esc with t-elif 1`] = `
|
exports[`t-if t-esc with t-elif 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
||||||
|
|
||||||
@@ -291,7 +305,8 @@ exports[`t-if t-esc with t-elif 1`] = `
|
|||||||
exports[`t-if t-esc with t-if 1`] = `
|
exports[`t-if t-esc with t-if 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -308,7 +323,8 @@ exports[`t-if t-esc with t-if 1`] = `
|
|||||||
exports[`t-if t-if and t-else with two nodes 1`] = `
|
exports[`t-if t-if and t-else with two nodes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block4 = createBlock(\`<span>a</span>\`);
|
let block4 = createBlock(\`<span>a</span>\`);
|
||||||
let block5 = createBlock(\`<span>b</span>\`);
|
let block5 = createBlock(\`<span>b</span>\`);
|
||||||
@@ -330,7 +346,8 @@ exports[`t-if t-if and t-else with two nodes 1`] = `
|
|||||||
exports[`t-if t-if in a div 1`] = `
|
exports[`t-if t-if in a div 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -347,7 +364,8 @@ exports[`t-if t-if in a div 1`] = `
|
|||||||
exports[`t-if t-if in a t-if 1`] = `
|
exports[`t-if t-if in a t-if 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block2 = createBlock(\`<span>1<block-child-0/></span>\`);
|
let block2 = createBlock(\`<span>1<block-child-0/></span>\`);
|
||||||
@@ -366,26 +384,11 @@ exports[`t-if t-if in a t-if 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-if t-if with empty content 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let b2,b3;
|
|
||||||
b2 = text(\`hello\`);
|
|
||||||
if (ctx['condition']) {
|
|
||||||
b3 = text(\`\`);
|
|
||||||
}
|
|
||||||
return multi([b2, b3]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-if t-if/t-else with more content 1`] = `
|
exports[`t-if t-if/t-else with more content 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2,b3;
|
let b2,b3;
|
||||||
@@ -404,8 +407,8 @@ exports[`t-if t-if/t-else with more content 1`] = `
|
|||||||
exports[`t-if t-set, then t-if 1`] = `
|
exports[`t-if t-set, then t-if 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -425,8 +428,8 @@ exports[`t-if t-set, then t-if 1`] = `
|
|||||||
exports[`t-if t-set, then t-if, part 2 1`] = `
|
exports[`t-if t-set, then t-if, part 2 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block2 = createBlock(\`<span>COUCOU</span>\`);
|
let block2 = createBlock(\`<span>COUCOU</span>\`);
|
||||||
@@ -448,8 +451,8 @@ exports[`t-if t-set, then t-if, part 2 1`] = `
|
|||||||
exports[`t-if t-set, then t-if, part 3 1`] = `
|
exports[`t-if t-set, then t-if, part 3 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
||||||
let block2 = createBlock(\`<span>AAA</span>\`);
|
let block2 = createBlock(\`<span>AAA</span>\`);
|
||||||
@@ -474,7 +477,8 @@ exports[`t-if t-set, then t-if, part 3 1`] = `
|
|||||||
exports[`t-if two consecutive t-if 1`] = `
|
exports[`t-if two consecutive t-if 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2,b3;
|
let b2,b3;
|
||||||
@@ -492,7 +496,8 @@ exports[`t-if two consecutive t-if 1`] = `
|
|||||||
exports[`t-if two consecutive t-if in a div 1`] = `
|
exports[`t-if two consecutive t-if in a div 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
||||||
|
|
||||||
@@ -512,7 +517,8 @@ exports[`t-if two consecutive t-if in a div 1`] = `
|
|||||||
exports[`t-if two t-ifs next to each other 1`] = `
|
exports[`t-if two t-ifs next to each other 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
||||||
let block2 = createBlock(\`<span><block-text-0/></span>\`);
|
let block2 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
@@ -522,8 +528,8 @@ exports[`t-if two t-ifs next to each other 1`] = `
|
|||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2,b3;
|
let b2,b3;
|
||||||
if (ctx['condition']) {
|
if (ctx['condition']) {
|
||||||
let txt1 = ctx['text'];
|
let d1 = ctx['text'];
|
||||||
b2 = block2([txt1]);
|
b2 = block2([d1]);
|
||||||
}
|
}
|
||||||
if (ctx['condition']) {
|
if (ctx['condition']) {
|
||||||
let b4 = block4();
|
let b4 = block4();
|
||||||
|
|||||||
@@ -3,14 +3,15 @@
|
|||||||
exports[`t-key can use t-key directive on a node 1`] = `
|
exports[`t-key can use t-key directive on a node 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const tKey_1 = ctx['beer'].id;
|
const tKey_1 = ctx['beer'].id;
|
||||||
let txt1 = ctx['beer'].name;
|
let d1 = ctx['beer'].name;
|
||||||
return toggler(tKey_1, block1([txt1]));
|
return toggler(tKey_1, block1([d1]));
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -18,14 +19,15 @@ exports[`t-key can use t-key directive on a node 1`] = `
|
|||||||
exports[`t-key can use t-key directive on a node 2 1`] = `
|
exports[`t-key can use t-key directive on a node 2 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const tKey_1 = ctx['beer'].id;
|
const tKey_1 = ctx['beer'].id;
|
||||||
let txt1 = ctx['beer'].name;
|
let d1 = ctx['beer'].name;
|
||||||
return toggler(tKey_1, block1([txt1]));
|
return toggler(tKey_1, block1([d1]));
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -33,14 +35,15 @@ exports[`t-key can use t-key directive on a node 2 1`] = `
|
|||||||
exports[`t-key can use t-key directive on a node as a function 1`] = `
|
exports[`t-key can use t-key directive on a node as a function 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const tKey_1 = ctx['getKey'](ctx['beer']);
|
const tKey_1 = ctx['getKey'](ctx['beer']);
|
||||||
let txt1 = ctx['beer'].name;
|
let d1 = ctx['beer'].name;
|
||||||
return toggler(tKey_1, block1([txt1]));
|
return toggler(tKey_1, block1([d1]));
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -48,8 +51,8 @@ exports[`t-key can use t-key directive on a node as a function 1`] = `
|
|||||||
exports[`t-key t-key directive in a list 1`] = `
|
exports[`t-key t-key directive in a list 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<ul><block-child-0/></ul>\`);
|
let block1 = createBlock(\`<ul><block-child-0/></ul>\`);
|
||||||
let block3 = createBlock(\`<li><block-text-0/></li>\`);
|
let block3 = createBlock(\`<li><block-text-0/></li>\`);
|
||||||
@@ -60,8 +63,8 @@ exports[`t-key t-key directive in a list 1`] = `
|
|||||||
for (let i1 = 0; i1 < l_block2; i1++) {
|
for (let i1 = 0; i1 < l_block2; i1++) {
|
||||||
ctx[\`beer\`] = v_block2[i1];
|
ctx[\`beer\`] = v_block2[i1];
|
||||||
let key1 = ctx['beer'].id;
|
let key1 = ctx['beer'].id;
|
||||||
let txt1 = ctx['beer'].name;
|
let d1 = ctx['beer'].name;
|
||||||
c_block2[i1] = withKey(block3([txt1]), key1);
|
c_block2[i1] = withKey(block3([d1]), key1);
|
||||||
}
|
}
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
exports[`t-out literal 1`] = `
|
exports[`t-out literal 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
|
|
||||||
@@ -18,8 +18,8 @@ exports[`t-out literal 1`] = `
|
|||||||
exports[`t-out literal, no outside html element 1`] = `
|
exports[`t-out literal, no outside html element 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return safeOutput('ok');
|
return safeOutput('ok');
|
||||||
@@ -30,29 +30,8 @@ exports[`t-out literal, no outside html element 1`] = `
|
|||||||
exports[`t-out multiple calls to t-out 1`] = `
|
exports[`t-out multiple calls to t-out 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, zero, getTemplate } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`sub\`);
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
||||||
let block2 = createBlock(\`<span>coucou</span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
ctx = Object.create(ctx);
|
|
||||||
ctx[isBoundary] = 1;
|
|
||||||
let b2 = block2();
|
|
||||||
ctx[zero] = b2;
|
|
||||||
let b3 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
|
||||||
return block1([], [b3]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-out multiple calls to t-out 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { zero } = helpers;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><div>Greeter</div><block-child-1/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><div>Greeter</div><block-child-1/></div>\`);
|
||||||
|
|
||||||
@@ -64,11 +43,32 @@ exports[`t-out multiple calls to t-out 2`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`t-out multiple calls to t-out 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
const callTemplate_2 = getTemplate(\`sub\`);
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
let block2 = createBlock(\`<span>coucou</span>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
ctx = Object.create(ctx);
|
||||||
|
ctx[isBoundary] = 1;
|
||||||
|
let b2 = block2();
|
||||||
|
ctx[zero] = b2;
|
||||||
|
let b3 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||||
|
return block1([], [b3]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`t-out not escaping 1`] = `
|
exports[`t-out not escaping 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -82,29 +82,8 @@ exports[`t-out not escaping 1`] = `
|
|||||||
exports[`t-out t-out 0 1`] = `
|
exports[`t-out t-out 0 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, zero, getTemplate } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`_basic-callee\`);
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
||||||
let block2 = createBlock(\`<div>zero</div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
ctx = Object.create(ctx);
|
|
||||||
ctx[isBoundary] = 1;
|
|
||||||
let b2 = block2();
|
|
||||||
ctx[zero] = b2;
|
|
||||||
let b3 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
|
||||||
return block1([], [b3]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-out t-out 0 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { zero } = helpers;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -115,11 +94,32 @@ exports[`t-out t-out 0 2`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`t-out t-out 0 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
const callTemplate_2 = getTemplate(\`_basic-callee\`);
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
let block2 = createBlock(\`<div>zero</div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
ctx = Object.create(ctx);
|
||||||
|
ctx[isBoundary] = 1;
|
||||||
|
let b2 = block2();
|
||||||
|
ctx[zero] = b2;
|
||||||
|
let b3 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||||
|
return block1([], [b3]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`t-out t-out and another sibling node 1`] = `
|
exports[`t-out t-out and another sibling node 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><span>hello</span><block-child-0/></span>\`);
|
let block1 = createBlock(\`<span><span>hello</span><block-child-0/></span>\`);
|
||||||
|
|
||||||
@@ -133,20 +133,17 @@ exports[`t-out t-out and another sibling node 1`] = `
|
|||||||
exports[`t-out t-out bdom 1`] = `
|
exports[`t-out t-out bdom 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, LazyValue, safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><span><block-child-0/></span></div>\`);
|
let block1 = createBlock(\`<div><span><block-child-0/></span></div>\`);
|
||||||
let block2 = createBlock(\`<ol>set</ol>\`);
|
let block2 = createBlock(\`<ol>set</ol>\`);
|
||||||
|
|
||||||
function value1(ctx, node, key = \\"\\") {
|
|
||||||
return block2();
|
|
||||||
}
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
ctx[\`var\`] = new LazyValue(value1, ctx, node);
|
let b2 = block2();
|
||||||
|
ctx[\`var\`] = b2;
|
||||||
let b3 = safeOutput(ctx['var']);
|
let b3 = safeOutput(ctx['var']);
|
||||||
return block1([], [b3]);
|
return block1([], [b3]);
|
||||||
}
|
}
|
||||||
@@ -156,8 +153,8 @@ exports[`t-out t-out bdom 1`] = `
|
|||||||
exports[`t-out t-out block 1`] = `
|
exports[`t-out t-out block 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
|
|
||||||
@@ -171,8 +168,8 @@ exports[`t-out t-out block 1`] = `
|
|||||||
exports[`t-out t-out escaped 1`] = `
|
exports[`t-out t-out escaped 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
|
|
||||||
@@ -186,8 +183,8 @@ exports[`t-out t-out escaped 1`] = `
|
|||||||
exports[`t-out t-out markedup 1`] = `
|
exports[`t-out t-out markedup 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
|
|
||||||
@@ -201,8 +198,8 @@ exports[`t-out t-out markedup 1`] = `
|
|||||||
exports[`t-out t-out on a node with a body, as a default 1`] = `
|
exports[`t-out t-out on a node with a body, as a default 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput, withDefault } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
|
|
||||||
@@ -217,8 +214,8 @@ exports[`t-out t-out on a node with a body, as a default 1`] = `
|
|||||||
exports[`t-out t-out on a node with a dom node in body, as a default 1`] = `
|
exports[`t-out t-out on a node with a dom node in body, as a default 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput, withDefault } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
let block3 = createBlock(\`<div>nope</div>\`);
|
let block3 = createBlock(\`<div>nope</div>\`);
|
||||||
@@ -234,8 +231,8 @@ exports[`t-out t-out on a node with a dom node in body, as a default 1`] = `
|
|||||||
exports[`t-out t-out switch escaped 1`] = `
|
exports[`t-out t-out switch escaped 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
|
|
||||||
@@ -249,8 +246,8 @@ exports[`t-out t-out switch escaped 1`] = `
|
|||||||
exports[`t-out t-out switch escaped on markup 1`] = `
|
exports[`t-out t-out switch escaped on markup 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
|
|
||||||
@@ -264,8 +261,8 @@ exports[`t-out t-out switch escaped on markup 1`] = `
|
|||||||
exports[`t-out t-out switch markup 1`] = `
|
exports[`t-out t-out switch markup 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
|
|
||||||
@@ -279,23 +276,20 @@ exports[`t-out t-out switch markup 1`] = `
|
|||||||
exports[`t-out t-out switch markup on bdom 1`] = `
|
exports[`t-out t-out switch markup on bdom 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, LazyValue, safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
||||||
let block2 = createBlock(\`<ol>set</ol>\`);
|
let block2 = createBlock(\`<ol>set</ol>\`);
|
||||||
let block3 = createBlock(\`<span><block-child-0/></span>\`);
|
let block3 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
let block5 = createBlock(\`<span><block-child-0/></span>\`);
|
let block5 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
|
|
||||||
function value1(ctx, node, key = \\"\\") {
|
|
||||||
return block2();
|
|
||||||
}
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
let b3,b5;
|
let b3,b5;
|
||||||
ctx[\`bdom\`] = new LazyValue(value1, ctx, node);
|
let b2 = block2();
|
||||||
|
ctx[\`bdom\`] = b2;
|
||||||
if (ctx['hasBdom']) {
|
if (ctx['hasBdom']) {
|
||||||
let b4 = safeOutput(ctx['bdom']);
|
let b4 = safeOutput(ctx['bdom']);
|
||||||
b3 = block3([], [b4]);
|
b3 = block3([], [b4]);
|
||||||
@@ -311,8 +305,8 @@ exports[`t-out t-out switch markup on bdom 1`] = `
|
|||||||
exports[`t-out t-out switch markup on escaped 1`] = `
|
exports[`t-out t-out switch markup on escaped 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
|
|
||||||
@@ -326,8 +320,8 @@ exports[`t-out t-out switch markup on escaped 1`] = `
|
|||||||
exports[`t-out t-out with a <t/> in body 1`] = `
|
exports[`t-out t-out with a <t/> in body 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return safeOutput(ctx['var']);
|
return safeOutput(ctx['var']);
|
||||||
@@ -338,8 +332,8 @@ exports[`t-out t-out with a <t/> in body 1`] = `
|
|||||||
exports[`t-out t-out with arbitrary object 1`] = `
|
exports[`t-out t-out with arbitrary object 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -353,8 +347,8 @@ exports[`t-out t-out with arbitrary object 1`] = `
|
|||||||
exports[`t-out t-out with arbitrary object 2 1`] = `
|
exports[`t-out t-out with arbitrary object 2 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -368,8 +362,8 @@ exports[`t-out t-out with arbitrary object 2 1`] = `
|
|||||||
exports[`t-out t-out with comment 1`] = `
|
exports[`t-out t-out with comment 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
|
|
||||||
@@ -383,8 +377,8 @@ exports[`t-out t-out with comment 1`] = `
|
|||||||
exports[`t-out t-out with just a t-set t-value in body 1`] = `
|
exports[`t-out t-out with just a t-set t-value in body 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return safeOutput(ctx['var']);
|
return safeOutput(ctx['var']);
|
||||||
@@ -395,8 +389,8 @@ exports[`t-out t-out with just a t-set t-value in body 1`] = `
|
|||||||
exports[`t-out variable 1`] = `
|
exports[`t-out variable 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
|
|
||||||
@@ -410,8 +404,8 @@ exports[`t-out variable 1`] = `
|
|||||||
exports[`t-raw is deprecated should warn 1`] = `
|
exports[`t-raw is deprecated should warn 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -425,8 +419,8 @@ exports[`t-raw is deprecated should warn 1`] = `
|
|||||||
exports[`t-raw is deprecated t-out is actually called in t-raw's place 1`] = `
|
exports[`t-raw is deprecated t-out is actually called in t-raw's place 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
|
|||||||
@@ -3,15 +3,16 @@
|
|||||||
exports[`t-ref can get a dynamic ref on a node 1`] = `
|
exports[`t-ref can get a dynamic ref on a node 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><span block-ref=\\"0\\"/></div>\`);
|
let block1 = createBlock(\`<div><span block-ref=\\"0\\"/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const refs = ctx.__owl__.refs;
|
const refs = ctx.__owl__.refs;
|
||||||
const v1 = ctx['id'];
|
const v1 = ctx['id'];
|
||||||
let ref1 = (el) => refs[\`myspan\${v1}\`] = el;
|
let d1 = (el) => refs[\`myspan\${v1}\`] = el;
|
||||||
return block1([ref1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -19,14 +20,15 @@ exports[`t-ref can get a dynamic ref on a node 1`] = `
|
|||||||
exports[`t-ref can get a ref on a node 1`] = `
|
exports[`t-ref can get a ref on a node 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><span block-ref=\\"0\\"/></div>\`);
|
let block1 = createBlock(\`<div><span block-ref=\\"0\\"/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const refs = ctx.__owl__.refs;
|
const refs = ctx.__owl__.refs;
|
||||||
const ref1 = (el) => refs[\`myspan\`] = el;
|
let d1 = (el) => refs[\`myspan\`] = el;
|
||||||
return block1([ref1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -34,14 +36,14 @@ exports[`t-ref can get a ref on a node 1`] = `
|
|||||||
exports[`t-ref ref in a t-call 1`] = `
|
exports[`t-ref ref in a t-call 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { getTemplate } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`sub\`);
|
const callTemplate_2 = getTemplate(\`sub\`);
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
let b2 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
@@ -50,14 +52,15 @@ exports[`t-ref ref in a t-call 1`] = `
|
|||||||
exports[`t-ref ref in a t-call 2`] = `
|
exports[`t-ref ref in a t-call 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>1<span block-ref=\\"0\\"/>2</div>\`);
|
let block1 = createBlock(\`<div>1<span block-ref=\\"0\\"/>2</div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const refs = ctx.__owl__.refs;
|
const refs = ctx.__owl__.refs;
|
||||||
const ref1 = (el) => refs[\`name\`] = el;
|
let d1 = (el) => refs[\`name\`] = el;
|
||||||
return block1([ref1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -65,17 +68,18 @@ exports[`t-ref ref in a t-call 2`] = `
|
|||||||
exports[`t-ref ref in a t-if 1`] = `
|
exports[`t-ref ref in a t-if 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block2 = createBlock(\`<span block-ref=\\"0\\"/>\`);
|
let block2 = createBlock(\`<span block-ref=\\"0\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const refs = ctx.__owl__.refs;
|
const refs = ctx.__owl__.refs;
|
||||||
const ref1 = (el) => refs[\`name\`] = el;
|
|
||||||
let b2;
|
let b2;
|
||||||
if (ctx['condition']) {
|
if (ctx['condition']) {
|
||||||
b2 = block2([ref1]);
|
let d1 = (el) => refs[\`name\`] = el;
|
||||||
|
b2 = block2([d1]);
|
||||||
}
|
}
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
}
|
}
|
||||||
@@ -85,8 +89,8 @@ exports[`t-ref ref in a t-if 1`] = `
|
|||||||
exports[`t-ref refs in a loop 1`] = `
|
exports[`t-ref refs in a loop 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block3 = createBlock(\`<div block-ref=\\"0\\"><block-text-1/></div>\`);
|
let block3 = createBlock(\`<div block-ref=\\"0\\"><block-text-1/></div>\`);
|
||||||
@@ -99,10 +103,10 @@ exports[`t-ref refs in a loop 1`] = `
|
|||||||
ctx[\`item\`] = v_block2[i1];
|
ctx[\`item\`] = v_block2[i1];
|
||||||
let key1 = ctx['item'];
|
let key1 = ctx['item'];
|
||||||
const tKey_1 = ctx['item'];
|
const tKey_1 = ctx['item'];
|
||||||
const v1 = ctx['item'];
|
const v2 = ctx['item'];
|
||||||
let ref1 = (el) => refs[\`\${v1}\`] = el;
|
let d1 = (el) => refs[\`\${v2}\`] = el;
|
||||||
let txt1 = ctx['item'];
|
let d2 = ctx['item'];
|
||||||
c_block2[i1] = withKey(block3([ref1, txt1]), tKey_1 + key1);
|
c_block2[i1] = withKey(block3([d1, d2]), tKey_1 + key1);
|
||||||
}
|
}
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
@@ -113,20 +117,21 @@ exports[`t-ref refs in a loop 1`] = `
|
|||||||
exports[`t-ref two refs, one in a t-if 1`] = `
|
exports[`t-ref two refs, one in a t-if 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><p block-ref=\\"0\\"/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><p block-ref=\\"0\\"/></div>\`);
|
||||||
let block2 = createBlock(\`<span block-ref=\\"0\\"/>\`);
|
let block2 = createBlock(\`<span block-ref=\\"0\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const refs = ctx.__owl__.refs;
|
const refs = ctx.__owl__.refs;
|
||||||
const ref1 = (el) => refs[\`name\`] = el;
|
|
||||||
const ref2 = (el) => refs[\`p\`] = el;
|
|
||||||
let b2;
|
let b2;
|
||||||
if (ctx['condition']) {
|
if (ctx['condition']) {
|
||||||
b2 = block2([ref1]);
|
let d1 = (el) => refs[\`name\`] = el;
|
||||||
|
b2 = block2([d1]);
|
||||||
}
|
}
|
||||||
return block1([ref2], [b2]);
|
let d2 = (el) => refs[\`p\`] = el;
|
||||||
|
return block1([d2], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
exports[`t-set evaluate value expression 1`] = `
|
exports[`t-set evaluate value expression 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
@@ -12,8 +12,8 @@ exports[`t-set evaluate value expression 1`] = `
|
|||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"value\\", 1+2);
|
setContextValue(ctx, \\"value\\", 1+2);
|
||||||
let txt1 = ctx['value'];
|
let d1 = ctx['value'];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -21,8 +21,8 @@ exports[`t-set evaluate value expression 1`] = `
|
|||||||
exports[`t-set evaluate value expression, part 2 1`] = `
|
exports[`t-set evaluate value expression, part 2 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
@@ -30,8 +30,8 @@ exports[`t-set evaluate value expression, part 2 1`] = `
|
|||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"value\\", ctx['somevariable']+2);
|
setContextValue(ctx, \\"value\\", ctx['somevariable']+2);
|
||||||
let txt1 = ctx['value'];
|
let d1 = ctx['value'];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -39,8 +39,8 @@ exports[`t-set evaluate value expression, part 2 1`] = `
|
|||||||
exports[`t-set set from attribute literal (no outside div) 1`] = `
|
exports[`t-set set from attribute literal (no outside div) 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
@@ -54,8 +54,8 @@ exports[`t-set set from attribute literal (no outside div) 1`] = `
|
|||||||
exports[`t-set set from attribute literal 1`] = `
|
exports[`t-set set from attribute literal 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
@@ -63,8 +63,8 @@ exports[`t-set set from attribute literal 1`] = `
|
|||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"value\\", 'ok');
|
setContextValue(ctx, \\"value\\", 'ok');
|
||||||
let txt1 = ctx['value'];
|
let d1 = ctx['value'];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -72,8 +72,8 @@ exports[`t-set set from attribute literal 1`] = `
|
|||||||
exports[`t-set set from attribute lookup 1`] = `
|
exports[`t-set set from attribute lookup 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
@@ -81,8 +81,8 @@ exports[`t-set set from attribute lookup 1`] = `
|
|||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"stuff\\", ctx['value']);
|
setContextValue(ctx, \\"stuff\\", ctx['value']);
|
||||||
let txt1 = ctx['stuff'];
|
let d1 = ctx['stuff'];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -90,8 +90,8 @@ exports[`t-set set from attribute lookup 1`] = `
|
|||||||
exports[`t-set set from body literal 1`] = `
|
exports[`t-set set from body literal 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
@@ -105,21 +105,18 @@ exports[`t-set set from body literal 1`] = `
|
|||||||
exports[`t-set set from body lookup 1`] = `
|
exports[`t-set set from body lookup 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, LazyValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
function value1(ctx, node, key = \\"\\") {
|
|
||||||
return text(ctx['value']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
ctx[\`stuff\`] = new LazyValue(value1, ctx, node);
|
let b2 = text(ctx['value']);
|
||||||
let txt1 = ctx['stuff'];
|
ctx[\`stuff\`] = b2;
|
||||||
return block1([txt1]);
|
let d1 = ctx['stuff'];
|
||||||
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -127,8 +124,8 @@ exports[`t-set set from body lookup 1`] = `
|
|||||||
exports[`t-set set from empty body 1`] = `
|
exports[`t-set set from empty body 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
@@ -136,8 +133,8 @@ exports[`t-set set from empty body 1`] = `
|
|||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"stuff\\", null);
|
setContextValue(ctx, \\"stuff\\", null);
|
||||||
let txt1 = ctx['stuff'];
|
let d1 = ctx['stuff'];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -145,8 +142,8 @@ exports[`t-set set from empty body 1`] = `
|
|||||||
exports[`t-set t-set and t-if 1`] = `
|
exports[`t-set t-set and t-if 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -166,22 +163,19 @@ exports[`t-set t-set and t-if 1`] = `
|
|||||||
exports[`t-set t-set body is evaluated immediately 1`] = `
|
exports[`t-set t-set body is evaluated immediately 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue, LazyValue, safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block2 = createBlock(\`<span><block-text-0/></span>\`);
|
let block2 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
function value1(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['v1'];
|
|
||||||
return block2([txt1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"v1\\", 'before');
|
setContextValue(ctx, \\"v1\\", 'before');
|
||||||
ctx[\`v2\`] = new LazyValue(value1, ctx, node);
|
let d1 = ctx['v1'];
|
||||||
|
let b2 = block2([d1]);
|
||||||
|
ctx[\`v2\`] = b2;
|
||||||
setContextValue(ctx, \\"v1\\", 'after');
|
setContextValue(ctx, \\"v1\\", 'after');
|
||||||
let b3 = safeOutput(ctx['v2']);
|
let b3 = safeOutput(ctx['v2']);
|
||||||
return block1([], [b3]);
|
return block1([], [b3]);
|
||||||
@@ -192,20 +186,18 @@ exports[`t-set t-set body is evaluated immediately 1`] = `
|
|||||||
exports[`t-set t-set can't alter from within callee 1`] = `
|
exports[`t-set t-set can't alter from within callee 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue, getTemplate } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`sub\`);
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><p><block-text-0/></p><block-child-0/><p><block-text-1/></p></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"iter\\", 'source');
|
let d1 = ctx['iter'];
|
||||||
let txt1 = ctx['iter'];
|
setContextValue(ctx, \\"iter\\", 'called');
|
||||||
let b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
let d2 = ctx['iter'];
|
||||||
let txt2 = ctx['iter'];
|
return block1([d1, d2]);
|
||||||
return block1([txt1, txt2], [b2]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -213,28 +205,9 @@ exports[`t-set t-set can't alter from within callee 1`] = `
|
|||||||
exports[`t-set t-set can't alter from within callee 2`] = `
|
exports[`t-set t-set can't alter from within callee 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
const callTemplate_2 = getTemplate(\`sub\`);
|
||||||
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
ctx = Object.create(ctx);
|
|
||||||
ctx[isBoundary] = 1
|
|
||||||
let txt1 = ctx['iter'];
|
|
||||||
setContextValue(ctx, \\"iter\\", 'called');
|
|
||||||
let txt2 = ctx['iter'];
|
|
||||||
return block1([txt1, txt2]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-set t-set can't alter in t-call body 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { isBoundary, withDefault, setContextValue, getTemplate } = helpers;
|
|
||||||
const callTemplate_1 = getTemplate(\`sub\`);
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><p><block-text-0/></p><block-child-0/><p><block-text-1/></p></div>\`);
|
let block1 = createBlock(\`<div><p><block-text-0/></p><block-child-0/><p><block-text-1/></p></div>\`);
|
||||||
|
|
||||||
@@ -242,14 +215,29 @@ exports[`t-set t-set can't alter in t-call body 1`] = `
|
|||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"iter\\", 'source');
|
setContextValue(ctx, \\"iter\\", 'source');
|
||||||
let txt1 = ctx['iter'];
|
let d1 = ctx['iter'];
|
||||||
|
let b2 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||||
|
let d2 = ctx['iter'];
|
||||||
|
return block1([d1, d2], [b2]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`t-set t-set can't alter in t-call body 1`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1;
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"iter\\", 'inCall');
|
let d1 = ctx['iter'];
|
||||||
let b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
setContextValue(ctx, \\"iter\\", 'called');
|
||||||
ctx = ctx.__proto__;
|
let d2 = ctx['iter'];
|
||||||
let txt2 = ctx['iter'];
|
return block1([d1, d2]);
|
||||||
return block1([txt1, txt2], [b2]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -257,18 +245,24 @@ exports[`t-set t-set can't alter in t-call body 1`] = `
|
|||||||
exports[`t-set t-set can't alter in t-call body 2`] = `
|
exports[`t-set t-set can't alter in t-call body 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
const callTemplate_2 = getTemplate(\`sub\`);
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
let block1 = createBlock(\`<div><p><block-text-0/></p><block-child-0/><p><block-text-1/></p></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
let txt1 = ctx['iter'];
|
setContextValue(ctx, \\"iter\\", 'source');
|
||||||
setContextValue(ctx, \\"iter\\", 'called');
|
let d1 = ctx['iter'];
|
||||||
let txt2 = ctx['iter'];
|
ctx = Object.create(ctx);
|
||||||
return block1([txt1, txt2]);
|
ctx[isBoundary] = 1;
|
||||||
|
setContextValue(ctx, \\"iter\\", 'inCall');
|
||||||
|
let b2 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||||
|
ctx = ctx.__proto__;
|
||||||
|
let d2 = ctx['iter'];
|
||||||
|
return block1([d1, d2], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -276,8 +270,8 @@ exports[`t-set t-set can't alter in t-call body 2`] = `
|
|||||||
exports[`t-set t-set does not modify render context existing key values 1`] = `
|
exports[`t-set t-set does not modify render context existing key values 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
@@ -285,8 +279,8 @@ exports[`t-set t-set does not modify render context existing key values 1`] = `
|
|||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"value\\", 35);
|
setContextValue(ctx, \\"value\\", 35);
|
||||||
let txt1 = ctx['value'];
|
let d1 = ctx['value'];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -294,8 +288,8 @@ exports[`t-set t-set does not modify render context existing key values 1`] = `
|
|||||||
exports[`t-set t-set evaluates an expression only once 1`] = `
|
exports[`t-set t-set evaluates an expression only once 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
||||||
|
|
||||||
@@ -303,9 +297,9 @@ exports[`t-set t-set evaluates an expression only once 1`] = `
|
|||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"v\\", ctx['value']+' artois');
|
setContextValue(ctx, \\"v\\", ctx['value']+' artois');
|
||||||
let txt1 = ctx['v'];
|
let d1 = ctx['v'];
|
||||||
let txt2 = ctx['v'];
|
let d2 = ctx['v'];
|
||||||
return block1([txt1, txt2]);
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -313,8 +307,8 @@ exports[`t-set t-set evaluates an expression only once 1`] = `
|
|||||||
exports[`t-set t-set outside modified in t-foreach 1`] = `
|
exports[`t-set t-set outside modified in t-foreach 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><p>EndLoop: <block-text-0/></p></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><p>EndLoop: <block-text-0/></p></div>\`);
|
||||||
let block3 = createBlock(\`<p>InLoop: <block-text-0/></p>\`);
|
let block3 = createBlock(\`<p>InLoop: <block-text-0/></p>\`);
|
||||||
@@ -328,14 +322,14 @@ exports[`t-set t-set outside modified in t-foreach 1`] = `
|
|||||||
for (let i1 = 0; i1 < l_block2; i1++) {
|
for (let i1 = 0; i1 < l_block2; i1++) {
|
||||||
ctx[\`val\`] = v_block2[i1];
|
ctx[\`val\`] = v_block2[i1];
|
||||||
let key1 = ctx['val'];
|
let key1 = ctx['val'];
|
||||||
let txt1 = ctx['iter'];
|
let d1 = ctx['iter'];
|
||||||
c_block2[i1] = withKey(block3([txt1]), key1);
|
c_block2[i1] = withKey(block3([d1]), key1);
|
||||||
setContextValue(ctx, \\"iter\\", ctx['iter']+1);
|
setContextValue(ctx, \\"iter\\", ctx['iter']+1);
|
||||||
}
|
}
|
||||||
ctx = ctx.__proto__;
|
ctx = ctx.__proto__;
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
let txt2 = ctx['iter'];
|
let d2 = ctx['iter'];
|
||||||
return block1([txt2], [b2]);
|
return block1([d2], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -343,8 +337,8 @@ exports[`t-set t-set outside modified in t-foreach 1`] = `
|
|||||||
exports[`t-set t-set outside modified in t-foreach increment-after operator 1`] = `
|
exports[`t-set t-set outside modified in t-foreach increment-after operator 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><p>EndLoop: <block-text-0/></p></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><p>EndLoop: <block-text-0/></p></div>\`);
|
||||||
let block3 = createBlock(\`<p>InLoop: <block-text-0/></p>\`);
|
let block3 = createBlock(\`<p>InLoop: <block-text-0/></p>\`);
|
||||||
@@ -358,14 +352,14 @@ exports[`t-set t-set outside modified in t-foreach increment-after operator 1`]
|
|||||||
for (let i1 = 0; i1 < l_block2; i1++) {
|
for (let i1 = 0; i1 < l_block2; i1++) {
|
||||||
ctx[\`val\`] = v_block2[i1];
|
ctx[\`val\`] = v_block2[i1];
|
||||||
let key1 = ctx['val'];
|
let key1 = ctx['val'];
|
||||||
let txt1 = ctx['iter'];
|
let d1 = ctx['iter'];
|
||||||
c_block2[i1] = withKey(block3([txt1]), key1);
|
c_block2[i1] = withKey(block3([d1]), key1);
|
||||||
setContextValue(ctx, \\"iter\\", ctx['iter']++);
|
setContextValue(ctx, \\"iter\\", ctx['iter']++);
|
||||||
}
|
}
|
||||||
ctx = ctx.__proto__;
|
ctx = ctx.__proto__;
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
let txt2 = ctx['iter'];
|
let d2 = ctx['iter'];
|
||||||
return block1([txt2], [b2]);
|
return block1([d2], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -373,8 +367,8 @@ exports[`t-set t-set outside modified in t-foreach increment-after operator 1`]
|
|||||||
exports[`t-set t-set outside modified in t-foreach increment-before operator 1`] = `
|
exports[`t-set t-set outside modified in t-foreach increment-before operator 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><p>EndLoop: <block-text-0/></p></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><p>EndLoop: <block-text-0/></p></div>\`);
|
||||||
let block3 = createBlock(\`<p>InLoop: <block-text-0/></p>\`);
|
let block3 = createBlock(\`<p>InLoop: <block-text-0/></p>\`);
|
||||||
@@ -388,14 +382,14 @@ exports[`t-set t-set outside modified in t-foreach increment-before operator 1`]
|
|||||||
for (let i1 = 0; i1 < l_block2; i1++) {
|
for (let i1 = 0; i1 < l_block2; i1++) {
|
||||||
ctx[\`val\`] = v_block2[i1];
|
ctx[\`val\`] = v_block2[i1];
|
||||||
let key1 = ctx['val'];
|
let key1 = ctx['val'];
|
||||||
let txt1 = ctx['iter'];
|
let d1 = ctx['iter'];
|
||||||
c_block2[i1] = withKey(block3([txt1]), key1);
|
c_block2[i1] = withKey(block3([d1]), key1);
|
||||||
setContextValue(ctx, \\"iter\\", ++ctx['iter']);
|
setContextValue(ctx, \\"iter\\", ++ctx['iter']);
|
||||||
}
|
}
|
||||||
ctx = ctx.__proto__;
|
ctx = ctx.__proto__;
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
let txt2 = ctx['iter'];
|
let d2 = ctx['iter'];
|
||||||
return block1([txt2], [b2]);
|
return block1([d2], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -403,8 +397,8 @@ exports[`t-set t-set outside modified in t-foreach increment-before operator 1`]
|
|||||||
exports[`t-set t-set should reuse variable if possible 1`] = `
|
exports[`t-set t-set should reuse variable if possible 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block3 = createBlock(\`<div><span>v<block-text-0/></span></div>\`);
|
let block3 = createBlock(\`<div><span>v<block-text-0/></span></div>\`);
|
||||||
@@ -419,9 +413,9 @@ exports[`t-set t-set should reuse variable if possible 1`] = `
|
|||||||
ctx[\`elem\`] = v_block2[i1];
|
ctx[\`elem\`] = v_block2[i1];
|
||||||
ctx[\`elem_index\`] = i1;
|
ctx[\`elem_index\`] = i1;
|
||||||
let key1 = ctx['elem_index'];
|
let key1 = ctx['elem_index'];
|
||||||
let txt1 = ctx['v'];
|
let d1 = ctx['v'];
|
||||||
setContextValue(ctx, \\"v\\", ctx['elem']);
|
setContextValue(ctx, \\"v\\", ctx['elem']);
|
||||||
c_block2[i1] = withKey(block3([txt1]), key1);
|
c_block2[i1] = withKey(block3([d1]), key1);
|
||||||
}
|
}
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
@@ -432,23 +426,20 @@ exports[`t-set t-set should reuse variable if possible 1`] = `
|
|||||||
exports[`t-set t-set with content and sub t-esc 1`] = `
|
exports[`t-set t-set with content and sub t-esc 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, LazyValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
function value1(ctx, node, key = \\"\\") {
|
|
||||||
let b3 = text(ctx['beep']);
|
|
||||||
let b4 = text(\` boop\`);
|
|
||||||
return multi([b3, b4]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
ctx[\`setvar\`] = new LazyValue(value1, ctx, node);
|
let b3 = text(ctx['beep']);
|
||||||
let txt1 = ctx['setvar'];
|
let b4 = text(\` boop\`);
|
||||||
return block1([txt1]);
|
let b2 = multi([b3, b4]);
|
||||||
|
ctx[\`setvar\`] = b2;
|
||||||
|
let d1 = ctx['setvar'];
|
||||||
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -456,23 +447,20 @@ exports[`t-set t-set with content and sub t-esc 1`] = `
|
|||||||
exports[`t-set t-set with t-value (falsy) and body 1`] = `
|
exports[`t-set t-set with t-value (falsy) and body 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue, LazyValue, safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block2 = createBlock(\`<span><block-text-0/></span>\`);
|
let block2 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
function value1(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['v1'];
|
|
||||||
return block2([txt1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"v3\\", false);
|
setContextValue(ctx, \\"v3\\", false);
|
||||||
setContextValue(ctx, \\"v1\\", 'before');
|
setContextValue(ctx, \\"v1\\", 'before');
|
||||||
ctx[\`v2\`] = withDefault(ctx['v3'], new LazyValue(value1, ctx, node));
|
let d1 = ctx['v1'];
|
||||||
|
let b2 = block2([d1]);
|
||||||
|
ctx[\`v2\`] = withDefault(ctx['v3'], b2);
|
||||||
setContextValue(ctx, \\"v1\\", 'after');
|
setContextValue(ctx, \\"v1\\", 'after');
|
||||||
setContextValue(ctx, \\"v3\\", true);
|
setContextValue(ctx, \\"v3\\", true);
|
||||||
let b3 = safeOutput(ctx['v2']);
|
let b3 = safeOutput(ctx['v2']);
|
||||||
@@ -484,23 +472,20 @@ exports[`t-set t-set with t-value (falsy) and body 1`] = `
|
|||||||
exports[`t-set t-set with t-value (truthy) and body 1`] = `
|
exports[`t-set t-set with t-value (truthy) and body 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue, LazyValue, safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block2 = createBlock(\`<span><block-text-0/></span>\`);
|
let block2 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
function value1(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['v1'];
|
|
||||||
return block2([txt1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"v3\\", 'Truthy');
|
setContextValue(ctx, \\"v3\\", 'Truthy');
|
||||||
setContextValue(ctx, \\"v1\\", 'before');
|
setContextValue(ctx, \\"v1\\", 'before');
|
||||||
ctx[\`v2\`] = withDefault(ctx['v3'], new LazyValue(value1, ctx, node));
|
let d1 = ctx['v1'];
|
||||||
|
let b2 = block2([d1]);
|
||||||
|
ctx[\`v2\`] = withDefault(ctx['v3'], b2);
|
||||||
setContextValue(ctx, \\"v1\\", 'after');
|
setContextValue(ctx, \\"v1\\", 'after');
|
||||||
setContextValue(ctx, \\"v3\\", false);
|
setContextValue(ctx, \\"v3\\", false);
|
||||||
let b3 = safeOutput(ctx['v2']);
|
let b3 = safeOutput(ctx['v2']);
|
||||||
@@ -512,8 +497,8 @@ exports[`t-set t-set with t-value (truthy) and body 1`] = `
|
|||||||
exports[`t-set t-set, t-if, and mix of expression/body lookup, 1 1`] = `
|
exports[`t-set t-set, t-if, and mix of expression/body lookup, 1 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-text-0/></div>\`);
|
||||||
|
|
||||||
@@ -525,8 +510,8 @@ exports[`t-set t-set, t-if, and mix of expression/body lookup, 1 1`] = `
|
|||||||
} else {
|
} else {
|
||||||
setContextValue(ctx, \\"ourvar\\", 0);
|
setContextValue(ctx, \\"ourvar\\", 0);
|
||||||
}
|
}
|
||||||
let txt1 = ctx['ourvar'];
|
let d1 = ctx['ourvar'];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -534,8 +519,8 @@ exports[`t-set t-set, t-if, and mix of expression/body lookup, 1 1`] = `
|
|||||||
exports[`t-set t-set, t-if, and mix of expression/body lookup, 2 1`] = `
|
exports[`t-set t-set, t-if, and mix of expression/body lookup, 2 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-text-0/></div>\`);
|
||||||
|
|
||||||
@@ -547,8 +532,8 @@ exports[`t-set t-set, t-if, and mix of expression/body lookup, 2 1`] = `
|
|||||||
} else {
|
} else {
|
||||||
setContextValue(ctx, \\"ourvar\\", \`0\`);
|
setContextValue(ctx, \\"ourvar\\", \`0\`);
|
||||||
}
|
}
|
||||||
let txt1 = ctx['ourvar'];
|
let d1 = ctx['ourvar'];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -556,8 +541,8 @@ exports[`t-set t-set, t-if, and mix of expression/body lookup, 2 1`] = `
|
|||||||
exports[`t-set t-set, t-if, and mix of expression/body lookup, 3 1`] = `
|
exports[`t-set t-set, t-if, and mix of expression/body lookup, 3 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
@@ -577,22 +562,19 @@ exports[`t-set t-set, t-if, and mix of expression/body lookup, 3 1`] = `
|
|||||||
exports[`t-set value priority (with non text body 1`] = `
|
exports[`t-set value priority (with non text body 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, LazyValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
let block2 = createBlock(\`<span>2</span>\`);
|
let block2 = createBlock(\`<span>2</span>\`);
|
||||||
|
|
||||||
function value1(ctx, node, key = \\"\\") {
|
|
||||||
return block2();
|
|
||||||
}
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
ctx[\`value\`] = withDefault(1, new LazyValue(value1, ctx, node));
|
let b2 = block2();
|
||||||
let txt1 = ctx['value'];
|
ctx[\`value\`] = withDefault(1, b2);
|
||||||
return block1([txt1]);
|
let d1 = ctx['value'];
|
||||||
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -600,8 +582,8 @@ exports[`t-set value priority (with non text body 1`] = `
|
|||||||
exports[`t-set value priority 1`] = `
|
exports[`t-set value priority 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
@@ -609,8 +591,8 @@ exports[`t-set value priority 1`] = `
|
|||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"value\\", withDefault(1, \`2\`));
|
setContextValue(ctx, \\"value\\", withDefault(1, \`2\`));
|
||||||
let txt1 = ctx['value'];
|
let d1 = ctx['value'];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
exports[`qweb t-tag can fallback if falsy tag 1`] = `
|
exports[`qweb t-tag can fallback if falsy tag 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = tag => createBlock(\`<\${tag || 'fallback'}/>\`);
|
let block1 = tag => createBlock(\`<\${tag || 'fallback'}/>\`);
|
||||||
|
|
||||||
@@ -17,7 +18,8 @@ exports[`qweb t-tag can fallback if falsy tag 1`] = `
|
|||||||
exports[`qweb t-tag can update 1`] = `
|
exports[`qweb t-tag can update 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = tag => createBlock(\`<\${tag || 't'}/>\`);
|
let block1 = tag => createBlock(\`<\${tag || 't'}/>\`);
|
||||||
|
|
||||||
@@ -31,7 +33,8 @@ exports[`qweb t-tag can update 1`] = `
|
|||||||
exports[`qweb t-tag simple usecases 1`] = `
|
exports[`qweb t-tag simple usecases 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = tag => createBlock(\`<\${tag || 't'}/>\`);
|
let block1 = tag => createBlock(\`<\${tag || 't'}/>\`);
|
||||||
|
|
||||||
@@ -45,7 +48,8 @@ exports[`qweb t-tag simple usecases 1`] = `
|
|||||||
exports[`qweb t-tag simple usecases 2`] = `
|
exports[`qweb t-tag simple usecases 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = tag => createBlock(\`<\${tag || 't'}>text</\${tag || 't'}>\`);
|
let block1 = tag => createBlock(\`<\${tag || 't'}>text</\${tag || 't'}>\`);
|
||||||
|
|
||||||
@@ -59,7 +63,8 @@ exports[`qweb t-tag simple usecases 2`] = `
|
|||||||
exports[`qweb t-tag with multiple attributes 1`] = `
|
exports[`qweb t-tag with multiple attributes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = tag => createBlock(\`<\${tag || 't'} class=\\"blueberry\\" taste=\\"raspberry\\">gooseberry</\${tag || 't'}>\`);
|
let block1 = tag => createBlock(\`<\${tag || 't'} class=\\"blueberry\\" taste=\\"raspberry\\">gooseberry</\${tag || 't'}>\`);
|
||||||
|
|
||||||
@@ -73,7 +78,8 @@ exports[`qweb t-tag with multiple attributes 1`] = `
|
|||||||
exports[`qweb t-tag with multiple child nodes 1`] = `
|
exports[`qweb t-tag with multiple child nodes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = tag => createBlock(\`<\${tag || 't'}> pear <span>apple</span> strawberry </\${tag || 't'}>\`);
|
let block1 = tag => createBlock(\`<\${tag || 't'}> pear <span>apple</span> strawberry </\${tag || 't'}>\`);
|
||||||
|
|
||||||
@@ -87,7 +93,8 @@ exports[`qweb t-tag with multiple child nodes 1`] = `
|
|||||||
exports[`qweb t-tag with multiple t-tag in same template 1`] = `
|
exports[`qweb t-tag with multiple t-tag in same template 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = tag => createBlock(\`<\${tag || 't'}><block-child-0/></\${tag || 't'}>\`);
|
let block1 = tag => createBlock(\`<\${tag || 't'}><block-child-0/></\${tag || 't'}>\`);
|
||||||
let block2 = tag => createBlock(\`<\${tag || 't'}>baz</\${tag || 't'}>\`);
|
let block2 = tag => createBlock(\`<\${tag || 't'}>baz</\${tag || 't'}>\`);
|
||||||
@@ -104,7 +111,8 @@ exports[`qweb t-tag with multiple t-tag in same template 1`] = `
|
|||||||
exports[`qweb t-tag with multiple t-tag in same template, part 2 1`] = `
|
exports[`qweb t-tag with multiple t-tag in same template, part 2 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block2 = tag => createBlock(\`<\${tag || 't'}>bar</\${tag || 't'}>\`);
|
let block2 = tag => createBlock(\`<\${tag || 't'}>bar</\${tag || 't'}>\`);
|
||||||
let block3 = tag => createBlock(\`<\${tag || 't'}>baz</\${tag || 't'}>\`);
|
let block3 = tag => createBlock(\`<\${tag || 't'}>baz</\${tag || 't'}>\`);
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
exports[`loading templates can initialize qweb with a string 1`] = `
|
exports[`loading templates can initialize qweb with a string 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>jupiler</div>\`);
|
let block1 = createBlock(\`<div>jupiler</div>\`);
|
||||||
|
|
||||||
@@ -16,7 +17,8 @@ exports[`loading templates can initialize qweb with a string 1`] = `
|
|||||||
exports[`loading templates can initialize qweb with an XMLDocument 1`] = `
|
exports[`loading templates can initialize qweb with an XMLDocument 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>jupiler</div>\`);
|
let block1 = createBlock(\`<div>jupiler</div>\`);
|
||||||
|
|
||||||
@@ -29,15 +31,16 @@ exports[`loading templates can initialize qweb with an XMLDocument 1`] = `
|
|||||||
exports[`loading templates can load a few templates from a xml string 1`] = `
|
exports[`loading templates can load a few templates from a xml string 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { getTemplate } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`items\`);
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<ul><block-child-0/></ul>\`);
|
let block2 = createBlock(\`<li>ok</li>\`);
|
||||||
|
let block3 = createBlock(\`<li>foo</li>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
let b2 = block2();
|
||||||
return block1([], [b2]);
|
let b3 = block3();
|
||||||
|
return multi([b2, b3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -45,15 +48,13 @@ exports[`loading templates can load a few templates from a xml string 1`] = `
|
|||||||
exports[`loading templates can load a few templates from a xml string 2`] = `
|
exports[`loading templates can load a few templates from a xml string 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block2 = createBlock(\`<li>ok</li>\`);
|
let block1 = createBlock(\`<ul/>\`);
|
||||||
let block3 = createBlock(\`<li>foo</li>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = block2();
|
return block1();
|
||||||
let b3 = block3();
|
|
||||||
return multi([b2, b3]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -61,23 +62,8 @@ exports[`loading templates can load a few templates from a xml string 2`] = `
|
|||||||
exports[`loading templates can load a few templates from an XMLDocument 1`] = `
|
exports[`loading templates can load a few templates from an XMLDocument 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { getTemplate } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`items\`);
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<ul><block-child-0/></ul>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
|
||||||
return block1([], [b2]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`loading templates can load a few templates from an XMLDocument 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block2 = createBlock(\`<li>ok</li>\`);
|
let block2 = createBlock(\`<li>ok</li>\`);
|
||||||
let block3 = createBlock(\`<li>foo</li>\`);
|
let block3 = createBlock(\`<li>foo</li>\`);
|
||||||
@@ -89,3 +75,17 @@ exports[`loading templates can load a few templates from an XMLDocument 2`] = `
|
|||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`loading templates can load a few templates from an XMLDocument 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<ul/>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return block1();
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
exports[`translation support can set translatable attributes 1`] = `
|
exports[`translation support can set translatable attributes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div tomato=\\"word\\" potato=\\"mot\\" title=\\"word\\">text</div>\`);
|
let block1 = createBlock(\`<div tomato=\\"word\\" potato=\\"mot\\" title=\\"word\\">text</div>\`);
|
||||||
|
|
||||||
@@ -16,7 +17,8 @@ exports[`translation support can set translatable attributes 1`] = `
|
|||||||
exports[`translation support can translate node content 1`] = `
|
exports[`translation support can translate node content 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>mot</div>\`);
|
let block1 = createBlock(\`<div>mot</div>\`);
|
||||||
|
|
||||||
@@ -29,7 +31,8 @@ exports[`translation support can translate node content 1`] = `
|
|||||||
exports[`translation support does not translate node content if disabled 1`] = `
|
exports[`translation support does not translate node content if disabled 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><span>mot</span><span>word</span></div>\`);
|
let block1 = createBlock(\`<div><span>mot</span><span>word</span></div>\`);
|
||||||
|
|
||||||
@@ -42,7 +45,8 @@ exports[`translation support does not translate node content if disabled 1`] = `
|
|||||||
exports[`translation support some attributes are translated 1`] = `
|
exports[`translation support some attributes are translated 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><p label=\\"mot\\">mot</p><p title=\\"mot\\">mot</p><p placeholder=\\"mot\\">mot</p><p alt=\\"mot\\">mot</p><p something=\\"word\\">mot</p></div>\`);
|
let block1 = createBlock(\`<div><p label=\\"mot\\">mot</p><p title=\\"mot\\">mot</p><p placeholder=\\"mot\\">mot</p><p alt=\\"mot\\">mot</p><p something=\\"word\\">mot</p></div>\`);
|
||||||
|
|
||||||
@@ -55,7 +59,8 @@ exports[`translation support some attributes are translated 1`] = `
|
|||||||
exports[`translation support translation is done on the trimmed text, with extra spaces readded after 1`] = `
|
exports[`translation support translation is done on the trimmed text, with extra spaces readded after 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div> mot </div>\`);
|
let block1 = createBlock(\`<div> mot </div>\`);
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
exports[`white space handling consecutives whitespaces are condensed into a single space 1`] = `
|
exports[`white space handling consecutives whitespaces are condensed into a single space 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div> abc </div>\`);
|
let block1 = createBlock(\`<div> abc </div>\`);
|
||||||
|
|
||||||
@@ -16,7 +17,8 @@ exports[`white space handling consecutives whitespaces are condensed into a sing
|
|||||||
exports[`white space handling nothing is done in pre tags 1`] = `
|
exports[`white space handling nothing is done in pre tags 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<pre> </pre>\`);
|
let block1 = createBlock(\`<pre> </pre>\`);
|
||||||
|
|
||||||
@@ -29,7 +31,8 @@ exports[`white space handling nothing is done in pre tags 1`] = `
|
|||||||
exports[`white space handling nothing is done in pre tags 2`] = `
|
exports[`white space handling nothing is done in pre tags 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<pre>
|
let block1 = createBlock(\`<pre>
|
||||||
some text
|
some text
|
||||||
@@ -44,7 +47,8 @@ exports[`white space handling nothing is done in pre tags 2`] = `
|
|||||||
exports[`white space handling nothing is done in pre tags 3`] = `
|
exports[`white space handling nothing is done in pre tags 3`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<pre>
|
let block1 = createBlock(\`<pre>
|
||||||
|
|
||||||
@@ -56,23 +60,11 @@ exports[`white space handling nothing is done in pre tags 3`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`white space handling pre inside a div with a new line 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><pre>SomeText</pre></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return block1();
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`white space handling white space only text nodes are condensed into a single space 1`] = `
|
exports[`white space handling white space only text nodes are condensed into a single space 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div> </div>\`);
|
let block1 = createBlock(\`<div> </div>\`);
|
||||||
|
|
||||||
@@ -85,7 +77,8 @@ exports[`white space handling white space only text nodes are condensed into a s
|
|||||||
exports[`white space handling whitespace only text nodes with newlines are removed 1`] = `
|
exports[`white space handling whitespace only text nodes with newlines are removed 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><span>abc</span></div>\`);
|
let block1 = createBlock(\`<div><span>abc</span></div>\`);
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { xml } from "../../src";
|
||||||
import { mount, patch } from "../../src/blockdom";
|
import { mount, patch } from "../../src/blockdom";
|
||||||
import { makeTestFixture, renderToBdom, renderToString, snapshotEverything } from "../helpers";
|
import { makeTestFixture, renderToBdom, renderToString, snapshotEverything } from "../helpers";
|
||||||
|
|
||||||
@@ -51,18 +52,6 @@ describe("attributes", () => {
|
|||||||
expect(result).toBe(`<div></div>`);
|
expect(result).toBe(`<div></div>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("dynamic undefined generic attribute", () => {
|
|
||||||
const template = `<div t-att-thing="c"/>`;
|
|
||||||
const result = renderToString(template, { c: undefined });
|
|
||||||
expect(result).toBe(`<div></div>`);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("dynamic undefined class attribute", () => {
|
|
||||||
const template = `<div t-att-class="c"/>`;
|
|
||||||
const result = renderToString(template, { c: undefined });
|
|
||||||
expect(result).toBe(`<div></div>`);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("dynamic attribute with a dash", () => {
|
test("dynamic attribute with a dash", () => {
|
||||||
const template = `<div t-att-data-action-id="id"/>`;
|
const template = `<div t-att-data-action-id="id"/>`;
|
||||||
const result = renderToString(template, { id: 32 });
|
const result = renderToString(template, { id: 32 });
|
||||||
@@ -347,8 +336,9 @@ describe("special cases for some specific html attributes/properties", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("various boolean html attributes", () => {
|
test("various boolean html attributes", () => {
|
||||||
// will cause the template to be snapshotted
|
// the unique assertion here is the code snapshot automatically done by
|
||||||
renderToString(`
|
// renderToString
|
||||||
|
xml`
|
||||||
<div>
|
<div>
|
||||||
<input type="checkbox" checked="checked"/>
|
<input type="checkbox" checked="checked"/>
|
||||||
<input checked="checked"/>
|
<input checked="checked"/>
|
||||||
@@ -358,7 +348,7 @@ describe("special cases for some specific html attributes/properties", () => {
|
|||||||
<input readonly="readonly"/>
|
<input readonly="readonly"/>
|
||||||
<button disabled="disabled"/>
|
<button disabled="disabled"/>
|
||||||
</div>
|
</div>
|
||||||
`);
|
`;
|
||||||
});
|
});
|
||||||
|
|
||||||
test("input with t-att-value", () => {
|
test("input with t-att-value", () => {
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
import {
|
import { xml } from "../../src";
|
||||||
renderToString,
|
import { renderToString, snapshotEverything, TestContext, trim } from "../helpers";
|
||||||
snapshotEverything,
|
|
||||||
snapshotTemplate,
|
|
||||||
TestContext,
|
|
||||||
trim,
|
|
||||||
} from "../helpers";
|
|
||||||
|
|
||||||
snapshotEverything();
|
snapshotEverything();
|
||||||
|
|
||||||
@@ -121,7 +116,7 @@ describe("misc", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("other complex template", () => {
|
test("other complex template", () => {
|
||||||
snapshotTemplate(`
|
xml`
|
||||||
<div>
|
<div>
|
||||||
<header>
|
<header>
|
||||||
<nav class="navbar navbar-expand-md navbar-light bg-light">
|
<nav class="navbar navbar-expand-md navbar-light bg-light">
|
||||||
@@ -262,6 +257,6 @@ describe("misc", () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>`);
|
</div>`;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+29
-186
@@ -146,94 +146,6 @@ describe("qweb parser", () => {
|
|||||||
content: [],
|
content: [],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
deepRemove: false,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test("dom node with t multi inside", async () => {
|
|
||||||
const template = `<div><t>Loading<t t-esc="abc"/></t></div>`;
|
|
||||||
expect(parse(template)).toEqual({
|
|
||||||
type: ASTType.DomNode,
|
|
||||||
tag: "div",
|
|
||||||
dynamicTag: null,
|
|
||||||
attrs: {},
|
|
||||||
on: {},
|
|
||||||
ref: null,
|
|
||||||
model: null,
|
|
||||||
ns: null,
|
|
||||||
content: [
|
|
||||||
{ type: ASTType.Text, value: "Loading" },
|
|
||||||
{ type: ASTType.TEsc, expr: "abc", defaultValue: "" },
|
|
||||||
],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test("dom node with multiple t multi inside", async () => {
|
|
||||||
const template = `
|
|
||||||
<div>
|
|
||||||
<t t-esc="a"/>
|
|
||||||
<t>
|
|
||||||
<t t-esc="b"/>
|
|
||||||
<t>Loading<t t-esc="c"/></t>
|
|
||||||
</t>
|
|
||||||
</div>`;
|
|
||||||
expect(parse(template)).toEqual({
|
|
||||||
type: ASTType.DomNode,
|
|
||||||
tag: "div",
|
|
||||||
dynamicTag: null,
|
|
||||||
attrs: {},
|
|
||||||
on: {},
|
|
||||||
ref: null,
|
|
||||||
model: null,
|
|
||||||
ns: null,
|
|
||||||
content: [
|
|
||||||
{ type: ASTType.TEsc, expr: "a", defaultValue: "" },
|
|
||||||
{ type: ASTType.TEsc, expr: "b", defaultValue: "" },
|
|
||||||
{ type: ASTType.Text, value: "Loading" },
|
|
||||||
{ type: ASTType.TEsc, expr: "c", defaultValue: "" },
|
|
||||||
],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test("dom node with t multi inside", async () => {
|
|
||||||
const template = `<div><t><t>Loading<t t-esc="abc"/></t></t></div>`;
|
|
||||||
expect(parse(template)).toEqual({
|
|
||||||
type: ASTType.DomNode,
|
|
||||||
tag: "div",
|
|
||||||
dynamicTag: null,
|
|
||||||
attrs: {},
|
|
||||||
on: {},
|
|
||||||
ref: null,
|
|
||||||
model: null,
|
|
||||||
ns: null,
|
|
||||||
content: [
|
|
||||||
{ type: ASTType.Text, value: "Loading" },
|
|
||||||
{ type: ASTType.TEsc, expr: "abc", defaultValue: "" },
|
|
||||||
],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test("dom node with two t multi inside", async () => {
|
|
||||||
const template = `
|
|
||||||
<div>
|
|
||||||
<t><t t-esc="a"/><t t-esc="b"/></t>
|
|
||||||
<t><t t-esc="c"/><t t-esc="d"/></t>
|
|
||||||
</div>`;
|
|
||||||
expect(parse(template)).toEqual({
|
|
||||||
type: ASTType.DomNode,
|
|
||||||
tag: "div",
|
|
||||||
dynamicTag: null,
|
|
||||||
attrs: {},
|
|
||||||
on: {},
|
|
||||||
ref: null,
|
|
||||||
model: null,
|
|
||||||
ns: null,
|
|
||||||
content: [
|
|
||||||
{ type: ASTType.TEsc, expr: "a", defaultValue: "" },
|
|
||||||
{ type: ASTType.TEsc, expr: "b", defaultValue: "" },
|
|
||||||
{ type: ASTType.TEsc, expr: "c", defaultValue: "" },
|
|
||||||
{ type: ASTType.TEsc, expr: "d", defaultValue: "" },
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -254,7 +166,6 @@ describe("qweb parser", () => {
|
|||||||
content: [],
|
content: [],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
deepRemove: false,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -344,32 +255,6 @@ describe("qweb parser", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("pre dom node with new line", async () => {
|
|
||||||
expect(parse(`<div><pre />\n</div>`)).toEqual({
|
|
||||||
type: 2,
|
|
||||||
tag: "div",
|
|
||||||
dynamicTag: null,
|
|
||||||
attrs: {},
|
|
||||||
on: {},
|
|
||||||
ref: null,
|
|
||||||
content: [
|
|
||||||
{
|
|
||||||
type: 2,
|
|
||||||
tag: "pre",
|
|
||||||
dynamicTag: null,
|
|
||||||
attrs: {},
|
|
||||||
on: {},
|
|
||||||
ref: null,
|
|
||||||
content: [],
|
|
||||||
model: null,
|
|
||||||
ns: null,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
model: null,
|
|
||||||
ns: null,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// t-esc
|
// t-esc
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -505,26 +390,11 @@ describe("qweb parser", () => {
|
|||||||
},
|
},
|
||||||
tElif: null,
|
tElif: null,
|
||||||
tElse: null,
|
tElse: null,
|
||||||
deepRemove: false,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("t-if with empty content", async () => {
|
|
||||||
expect(parse(`<t t-if="condition"></t>`)).toEqual({
|
|
||||||
type: ASTType.TIf,
|
|
||||||
condition: "condition",
|
|
||||||
content: {
|
|
||||||
type: ASTType.Text,
|
|
||||||
value: "",
|
|
||||||
},
|
|
||||||
tElif: null,
|
|
||||||
tElse: null,
|
|
||||||
deepRemove: false,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test("t-if (on dom node", async () => {
|
test("t-if (on dom node", async () => {
|
||||||
expect(parse(`<div t-if="condition">hey</div>`)).toEqual({
|
expect(parse(`<div t-if="condition">hey</div>`)).toEqual({
|
||||||
type: ASTType.TIf,
|
type: ASTType.TIf,
|
||||||
@@ -542,7 +412,6 @@ describe("qweb parser", () => {
|
|||||||
},
|
},
|
||||||
tElif: null,
|
tElif: null,
|
||||||
tElse: null,
|
tElse: null,
|
||||||
deepRemove: false,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -559,7 +428,6 @@ describe("qweb parser", () => {
|
|||||||
type: ASTType.Text,
|
type: ASTType.Text,
|
||||||
value: "else",
|
value: "else",
|
||||||
},
|
},
|
||||||
deepRemove: false,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -578,7 +446,6 @@ describe("qweb parser", () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
tElse: null,
|
tElse: null,
|
||||||
deepRemove: false,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -600,7 +467,6 @@ describe("qweb parser", () => {
|
|||||||
type: ASTType.Text,
|
type: ASTType.Text,
|
||||||
value: "else",
|
value: "else",
|
||||||
},
|
},
|
||||||
deepRemove: false,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -658,7 +524,6 @@ describe("qweb parser", () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
deepRemove: false,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -740,7 +605,6 @@ describe("qweb parser", () => {
|
|||||||
},
|
},
|
||||||
tElif: null,
|
tElif: null,
|
||||||
tElse: null,
|
tElse: null,
|
||||||
deepRemove: false,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -763,7 +627,6 @@ describe("qweb parser", () => {
|
|||||||
content: { type: ASTType.Text, value: "1" },
|
content: { type: ASTType.Text, value: "1" },
|
||||||
tElif: null,
|
tElif: null,
|
||||||
tElse: { type: ASTType.TSet, name: "ourvar", value: "0", defaultValue: null, body: null },
|
tElse: { type: ASTType.TSet, name: "ourvar", value: "0", defaultValue: null, body: null },
|
||||||
deepRemove: false,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@@ -787,13 +650,14 @@ describe("qweb parser", () => {
|
|||||||
collection: "list",
|
collection: "list",
|
||||||
elem: "item",
|
elem: "item",
|
||||||
key: "item_index",
|
key: "item_index",
|
||||||
|
hasNoComponent: true,
|
||||||
|
isOnlyChild: false,
|
||||||
body: { type: ASTType.TEsc, expr: "item", defaultValue: "" },
|
body: { type: ASTType.TEsc, expr: "item", defaultValue: "" },
|
||||||
memo: "",
|
memo: "",
|
||||||
hasNoFirst: true,
|
hasNoFirst: true,
|
||||||
hasNoIndex: false,
|
hasNoIndex: false,
|
||||||
hasNoLast: true,
|
hasNoLast: true,
|
||||||
hasNoValue: true,
|
hasNoValue: true,
|
||||||
deepRemove: false,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -803,13 +667,14 @@ describe("qweb parser", () => {
|
|||||||
collection: "list",
|
collection: "list",
|
||||||
elem: "item",
|
elem: "item",
|
||||||
key: "item_index",
|
key: "item_index",
|
||||||
|
hasNoComponent: true,
|
||||||
|
isOnlyChild: false,
|
||||||
body: { type: ASTType.TEsc, expr: "item", defaultValue: "" },
|
body: { type: ASTType.TEsc, expr: "item", defaultValue: "" },
|
||||||
memo: "",
|
memo: "",
|
||||||
hasNoFirst: true,
|
hasNoFirst: true,
|
||||||
hasNoIndex: false,
|
hasNoIndex: false,
|
||||||
hasNoLast: true,
|
hasNoLast: true,
|
||||||
hasNoValue: true,
|
hasNoValue: true,
|
||||||
deepRemove: false,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -818,6 +683,8 @@ describe("qweb parser", () => {
|
|||||||
type: ASTType.TForEach,
|
type: ASTType.TForEach,
|
||||||
collection: "list",
|
collection: "list",
|
||||||
elem: "item",
|
elem: "item",
|
||||||
|
hasNoComponent: true,
|
||||||
|
isOnlyChild: false,
|
||||||
key: "item_index",
|
key: "item_index",
|
||||||
body: {
|
body: {
|
||||||
type: ASTType.DomNode,
|
type: ASTType.DomNode,
|
||||||
@@ -835,7 +702,6 @@ describe("qweb parser", () => {
|
|||||||
hasNoIndex: false,
|
hasNoIndex: false,
|
||||||
hasNoLast: true,
|
hasNoLast: true,
|
||||||
hasNoValue: true,
|
hasNoValue: true,
|
||||||
deepRemove: false,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -844,6 +710,8 @@ describe("qweb parser", () => {
|
|||||||
type: ASTType.TForEach,
|
type: ASTType.TForEach,
|
||||||
collection: "list",
|
collection: "list",
|
||||||
elem: "item",
|
elem: "item",
|
||||||
|
hasNoComponent: true,
|
||||||
|
isOnlyChild: false,
|
||||||
key: "item.id",
|
key: "item.id",
|
||||||
body: { type: ASTType.TEsc, expr: "item", defaultValue: "" },
|
body: { type: ASTType.TEsc, expr: "item", defaultValue: "" },
|
||||||
memo: "",
|
memo: "",
|
||||||
@@ -851,7 +719,6 @@ describe("qweb parser", () => {
|
|||||||
hasNoIndex: true,
|
hasNoIndex: true,
|
||||||
hasNoLast: true,
|
hasNoLast: true,
|
||||||
hasNoValue: true,
|
hasNoValue: true,
|
||||||
deepRemove: false,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -863,6 +730,8 @@ describe("qweb parser", () => {
|
|||||||
collection: "list",
|
collection: "list",
|
||||||
elem: "item",
|
elem: "item",
|
||||||
key: "item_index",
|
key: "item_index",
|
||||||
|
hasNoComponent: true,
|
||||||
|
isOnlyChild: false,
|
||||||
body: {
|
body: {
|
||||||
type: ASTType.DomNode,
|
type: ASTType.DomNode,
|
||||||
tag: "span",
|
tag: "span",
|
||||||
@@ -879,7 +748,6 @@ describe("qweb parser", () => {
|
|||||||
hasNoIndex: false,
|
hasNoIndex: false,
|
||||||
hasNoLast: true,
|
hasNoLast: true,
|
||||||
hasNoValue: true,
|
hasNoValue: true,
|
||||||
deepRemove: false,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -893,12 +761,13 @@ describe("qweb parser", () => {
|
|||||||
collection: "list",
|
collection: "list",
|
||||||
elem: "item",
|
elem: "item",
|
||||||
key: "item_index",
|
key: "item_index",
|
||||||
|
hasNoComponent: true,
|
||||||
|
isOnlyChild: false,
|
||||||
body: {
|
body: {
|
||||||
type: ASTType.TIf,
|
type: ASTType.TIf,
|
||||||
condition: "condition",
|
condition: "condition",
|
||||||
tElif: null,
|
tElif: null,
|
||||||
tElse: null,
|
tElse: null,
|
||||||
deepRemove: false,
|
|
||||||
content: {
|
content: {
|
||||||
type: ASTType.DomNode,
|
type: ASTType.DomNode,
|
||||||
tag: "span",
|
tag: "span",
|
||||||
@@ -916,7 +785,6 @@ describe("qweb parser", () => {
|
|||||||
hasNoIndex: false,
|
hasNoIndex: false,
|
||||||
hasNoLast: true,
|
hasNoLast: true,
|
||||||
hasNoValue: true,
|
hasNoValue: true,
|
||||||
deepRemove: false,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -930,6 +798,8 @@ describe("qweb parser", () => {
|
|||||||
collection: "categories",
|
collection: "categories",
|
||||||
elem: "category",
|
elem: "category",
|
||||||
key: "category_index",
|
key: "category_index",
|
||||||
|
hasNoComponent: true,
|
||||||
|
isOnlyChild: false,
|
||||||
body: {
|
body: {
|
||||||
type: ASTType.DomNode,
|
type: ASTType.DomNode,
|
||||||
tag: "option",
|
tag: "option",
|
||||||
@@ -949,7 +819,6 @@ describe("qweb parser", () => {
|
|||||||
hasNoIndex: false,
|
hasNoIndex: false,
|
||||||
hasNoLast: true,
|
hasNoLast: true,
|
||||||
hasNoValue: true,
|
hasNoValue: true,
|
||||||
deepRemove: false,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -971,13 +840,14 @@ describe("qweb parser", () => {
|
|||||||
collection: "list",
|
collection: "list",
|
||||||
elem: "item",
|
elem: "item",
|
||||||
key: "item_index",
|
key: "item_index",
|
||||||
|
hasNoComponent: true,
|
||||||
|
isOnlyChild: true,
|
||||||
body: { type: ASTType.TEsc, expr: "item", defaultValue: "" },
|
body: { type: ASTType.TEsc, expr: "item", defaultValue: "" },
|
||||||
memo: "",
|
memo: "",
|
||||||
hasNoFirst: true,
|
hasNoFirst: true,
|
||||||
hasNoIndex: false,
|
hasNoIndex: false,
|
||||||
hasNoLast: true,
|
hasNoLast: true,
|
||||||
hasNoValue: true,
|
hasNoValue: true,
|
||||||
deepRemove: false,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@@ -999,6 +869,8 @@ describe("qweb parser", () => {
|
|||||||
collection: "list",
|
collection: "list",
|
||||||
elem: "item",
|
elem: "item",
|
||||||
key: "item_index",
|
key: "item_index",
|
||||||
|
hasNoComponent: true,
|
||||||
|
isOnlyChild: false,
|
||||||
body: {
|
body: {
|
||||||
type: ASTType.DomNode,
|
type: ASTType.DomNode,
|
||||||
tag: "span",
|
tag: "span",
|
||||||
@@ -1015,7 +887,6 @@ describe("qweb parser", () => {
|
|||||||
hasNoIndex: false,
|
hasNoIndex: false,
|
||||||
hasNoLast: true,
|
hasNoLast: true,
|
||||||
hasNoValue: true,
|
hasNoValue: true,
|
||||||
deepRemove: false,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1025,6 +896,8 @@ describe("qweb parser", () => {
|
|||||||
collection: "list",
|
collection: "list",
|
||||||
elem: "item",
|
elem: "item",
|
||||||
key: "item_index",
|
key: "item_index",
|
||||||
|
hasNoComponent: false,
|
||||||
|
isOnlyChild: false,
|
||||||
body: {
|
body: {
|
||||||
type: ASTType.TComponent,
|
type: ASTType.TComponent,
|
||||||
isDynamic: false,
|
isDynamic: false,
|
||||||
@@ -1038,7 +911,6 @@ describe("qweb parser", () => {
|
|||||||
hasNoIndex: false,
|
hasNoIndex: false,
|
||||||
hasNoLast: true,
|
hasNoLast: true,
|
||||||
hasNoValue: true,
|
hasNoValue: true,
|
||||||
deepRemove: false,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1050,6 +922,8 @@ describe("qweb parser", () => {
|
|||||||
collection: "list",
|
collection: "list",
|
||||||
elem: "item",
|
elem: "item",
|
||||||
key: "item_index",
|
key: "item_index",
|
||||||
|
hasNoComponent: false,
|
||||||
|
isOnlyChild: false,
|
||||||
body: {
|
body: {
|
||||||
type: ASTType.TCall,
|
type: ASTType.TCall,
|
||||||
name: "blap",
|
name: "blap",
|
||||||
@@ -1060,7 +934,6 @@ describe("qweb parser", () => {
|
|||||||
hasNoIndex: false,
|
hasNoIndex: false,
|
||||||
hasNoLast: false,
|
hasNoLast: false,
|
||||||
hasNoValue: false,
|
hasNoValue: false,
|
||||||
deepRemove: false,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1074,13 +947,14 @@ describe("qweb parser", () => {
|
|||||||
collection: "list",
|
collection: "list",
|
||||||
elem: "item",
|
elem: "item",
|
||||||
key: "item_index",
|
key: "item_index",
|
||||||
|
hasNoComponent: true,
|
||||||
|
isOnlyChild: false,
|
||||||
body: { type: ASTType.TEsc, expr: "item", defaultValue: "" },
|
body: { type: ASTType.TEsc, expr: "item", defaultValue: "" },
|
||||||
memo: "[row.x]",
|
memo: "[row.x]",
|
||||||
hasNoFirst: true,
|
hasNoFirst: true,
|
||||||
hasNoIndex: false,
|
hasNoIndex: false,
|
||||||
hasNoLast: true,
|
hasNoLast: true,
|
||||||
hasNoValue: true,
|
hasNoValue: true,
|
||||||
deepRemove: false,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1130,7 +1004,6 @@ describe("qweb parser", () => {
|
|||||||
condition: "condition",
|
condition: "condition",
|
||||||
tElif: null,
|
tElif: null,
|
||||||
tElse: null,
|
tElse: null,
|
||||||
deepRemove: false,
|
|
||||||
content: {
|
content: {
|
||||||
type: ASTType.TCall,
|
type: ASTType.TCall,
|
||||||
name: "blabla",
|
name: "blabla",
|
||||||
@@ -1285,7 +1158,6 @@ describe("qweb parser", () => {
|
|||||||
ns: null,
|
ns: null,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
deepRemove: false,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -1606,7 +1478,7 @@ describe("qweb parser", () => {
|
|||||||
attrs: {},
|
attrs: {},
|
||||||
content: [
|
content: [
|
||||||
{
|
{
|
||||||
type: ASTType.Text,
|
type: 0,
|
||||||
value: "word",
|
value: "word",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -1618,18 +1490,19 @@ describe("qweb parser", () => {
|
|||||||
type: ASTType.DomNode,
|
type: ASTType.DomNode,
|
||||||
ns: null,
|
ns: null,
|
||||||
},
|
},
|
||||||
type: ASTType.TTranslation,
|
type: 16,
|
||||||
},
|
},
|
||||||
collection: "list",
|
collection: "list",
|
||||||
elem: "item",
|
elem: "item",
|
||||||
|
hasNoComponent: true,
|
||||||
hasNoFirst: true,
|
hasNoFirst: true,
|
||||||
hasNoIndex: false,
|
hasNoIndex: false,
|
||||||
hasNoLast: true,
|
hasNoLast: true,
|
||||||
hasNoValue: true,
|
hasNoValue: true,
|
||||||
|
isOnlyChild: false,
|
||||||
key: "item_index",
|
key: "item_index",
|
||||||
memo: "",
|
memo: "",
|
||||||
deepRemove: false,
|
type: 9,
|
||||||
type: ASTType.TForEach,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1788,34 +1661,4 @@ describe("qweb parser", () => {
|
|||||||
ns: null,
|
ns: null,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// t-portal
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
test("t-portal", async () => {
|
|
||||||
expect(parse(`<t t-portal="target">Content</t>`)).toEqual({
|
|
||||||
type: ASTType.TPortal,
|
|
||||||
target: "target",
|
|
||||||
content: { type: ASTType.Text, value: "Content" },
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test("t-portal must be in a <t> node", async () => {
|
|
||||||
expect(() => parse(`<div t-portal="target">Content</div>`)).toThrowError();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("t-portal with t-if", async () => {
|
|
||||||
expect(parse(`<t t-portal="target" t-if="condition">Content</t>`)).toEqual({
|
|
||||||
condition: "condition",
|
|
||||||
content: {
|
|
||||||
content: { type: ASTType.Text, value: "Content" },
|
|
||||||
target: "target",
|
|
||||||
type: ASTType.TPortal,
|
|
||||||
},
|
|
||||||
tElif: null,
|
|
||||||
tElse: null,
|
|
||||||
type: ASTType.TIf,
|
|
||||||
deepRemove: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -137,21 +137,4 @@ describe("simple templates, mostly static", () => {
|
|||||||
const template = '<t><t t-esc="`text ${v}`"/></t>';
|
const template = '<t><t t-esc="`text ${v}`"/></t>';
|
||||||
expect(renderToString(template, { v: "from context" })).toBe("text from context");
|
expect(renderToString(template, { v: "from context" })).toBe("text from context");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("template with t tag with multiple content", () => {
|
|
||||||
const template = `<div><t>Loading<t t-if="false"/></t></div>`;
|
|
||||||
expect(renderToString(template)).toBe("<div>Loading</div>");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("template with multiple t tag with multiple content", () => {
|
|
||||||
const template = `
|
|
||||||
<div>
|
|
||||||
<t t-esc="a"/>
|
|
||||||
<t>
|
|
||||||
<t t-esc="b"/>
|
|
||||||
<t>Loading<t t-esc="c"/></t>
|
|
||||||
</t>
|
|
||||||
</div>`;
|
|
||||||
expect(renderToString(template, { a: "a", b: "b", c: "c" })).toBe("<div>abLoadingc</div>");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { renderToString, snapshotTemplate } from "../helpers";
|
import { renderToString, snapshotTemplateCode } from "../helpers";
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// debugging
|
// debugging
|
||||||
@@ -9,7 +9,7 @@ describe("debugging", () => {
|
|||||||
const consoleLog = console.log;
|
const consoleLog = console.log;
|
||||||
console.log = jest.fn();
|
console.log = jest.fn();
|
||||||
const template = `<div t-debug=""><t t-if="true"><span t-debug="">hey</span></t></div>`;
|
const template = `<div t-debug=""><t t-if="true"><span t-debug="">hey</span></t></div>`;
|
||||||
snapshotTemplate(template);
|
snapshotTemplateCode(template);
|
||||||
expect(console.log).toHaveBeenCalledTimes(1);
|
expect(console.log).toHaveBeenCalledTimes(1);
|
||||||
console.log = consoleLog;
|
console.log = consoleLog;
|
||||||
});
|
});
|
||||||
@@ -18,9 +18,9 @@ describe("debugging", () => {
|
|||||||
const consoleLog = console.log;
|
const consoleLog = console.log;
|
||||||
console.log = jest.fn();
|
console.log = jest.fn();
|
||||||
let template = `<p t-debug="">coucou</p>`;
|
let template = `<p t-debug="">coucou</p>`;
|
||||||
snapshotTemplate(template);
|
snapshotTemplateCode(template);
|
||||||
template = `<div><t t-call="sub"/></div>`;
|
template = `<div><t t-call="sub"/></div>`;
|
||||||
snapshotTemplate(template);
|
snapshotTemplateCode(template);
|
||||||
expect(console.log).toHaveBeenCalledTimes(1);
|
expect(console.log).toHaveBeenCalledTimes(1);
|
||||||
console.log = consoleLog;
|
console.log = consoleLog;
|
||||||
});
|
});
|
||||||
@@ -33,7 +33,7 @@ describe("debugging", () => {
|
|||||||
<t t-set="foo" t-value="42"/>
|
<t t-set="foo" t-value="42"/>
|
||||||
<t t-log="foo + 3"/>
|
<t t-log="foo + 3"/>
|
||||||
</div>`;
|
</div>`;
|
||||||
snapshotTemplate(template);
|
snapshotTemplateCode(template);
|
||||||
renderToString(template);
|
renderToString(template);
|
||||||
expect(console.log).toHaveBeenCalledWith(45);
|
expect(console.log).toHaveBeenCalledWith(45);
|
||||||
console.log = consoleLog;
|
console.log = consoleLog;
|
||||||
|
|||||||
@@ -16,12 +16,6 @@ describe("t-if", () => {
|
|||||||
expect(renderToString(template, {})).toBe("<div></div>");
|
expect(renderToString(template, {})).toBe("<div></div>");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("t-if with empty content", () => {
|
|
||||||
const template = `hello<t t-if="condition"/>`;
|
|
||||||
expect(renderToString(template, { condition: true })).toBe("hello");
|
|
||||||
expect(renderToString(template, { condition: false })).toBe("hello");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("boolean value condition missing", () => {
|
test("boolean value condition missing", () => {
|
||||||
const template = `<span><t t-if="condition">fail</t></span>`;
|
const template = `<span><t t-if="condition">fail</t></span>`;
|
||||||
expect(renderToString(template)).toBe("<span></span>");
|
expect(renderToString(template)).toBe("<span></span>");
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { Component, mount, xml } from "../../src";
|
import { App, Component } from "../../src";
|
||||||
import { makeTestFixture, snapshotEverything } from "../helpers";
|
import { makeTestFixture, snapshotApp } from "../helpers";
|
||||||
|
import { xml } from "../../src/tags";
|
||||||
|
|
||||||
let fixture: HTMLElement;
|
let fixture: HTMLElement;
|
||||||
|
|
||||||
snapshotEverything();
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = makeTestFixture();
|
fixture = makeTestFixture();
|
||||||
});
|
});
|
||||||
@@ -15,10 +14,16 @@ describe("translation support", () => {
|
|||||||
static template = xml`<div>word</div>`;
|
static template = xml`<div>word</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
await mount(SomeComponent, fixture, {
|
const app = new App(SomeComponent);
|
||||||
|
app.configure({
|
||||||
translateFn: (expr: string) => (expr === "word" ? "mot" : expr),
|
translateFn: (expr: string) => (expr === "word" ? "mot" : expr),
|
||||||
});
|
});
|
||||||
expect(fixture.innerHTML).toBe("<div>mot</div>");
|
const comp = await app.mount(fixture);
|
||||||
|
|
||||||
|
const el = comp.el as HTMLElement;
|
||||||
|
|
||||||
|
expect(el.outerHTML).toBe("<div>mot</div>");
|
||||||
|
snapshotApp(app);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("does not translate node content if disabled", async () => {
|
test("does not translate node content if disabled", async () => {
|
||||||
@@ -31,11 +36,16 @@ describe("translation support", () => {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
await mount(SomeComponent, fixture, {
|
const app = new App(SomeComponent);
|
||||||
|
app.configure({
|
||||||
translateFn: (expr: string) => (expr === "word" ? "mot" : expr),
|
translateFn: (expr: string) => (expr === "word" ? "mot" : expr),
|
||||||
});
|
});
|
||||||
|
const comp = await app.mount(fixture);
|
||||||
|
|
||||||
expect(fixture.innerHTML).toBe("<div><span>mot</span><span>word</span></div>");
|
const el = comp.el as HTMLElement;
|
||||||
|
|
||||||
|
expect(el.outerHTML).toBe("<div><span>mot</span><span>word</span></div>");
|
||||||
|
snapshotApp(app);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("some attributes are translated", async () => {
|
test("some attributes are translated", async () => {
|
||||||
@@ -51,12 +61,18 @@ describe("translation support", () => {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
await mount(SomeComponent, fixture, {
|
const app = new App(SomeComponent);
|
||||||
|
app.configure({
|
||||||
translateFn: (expr: string) => (expr === "word" ? "mot" : expr),
|
translateFn: (expr: string) => (expr === "word" ? "mot" : expr),
|
||||||
});
|
});
|
||||||
expect(fixture.innerHTML).toBe(
|
const comp = await app.mount(fixture);
|
||||||
|
|
||||||
|
const el = comp.el as HTMLElement;
|
||||||
|
|
||||||
|
expect(el.outerHTML).toBe(
|
||||||
'<div><p label="mot">mot</p><p title="mot">mot</p><p placeholder="mot">mot</p><p alt="mot">mot</p><p something="word">mot</p></div>'
|
'<div><p label="mot">mot</p><p title="mot">mot</p><p placeholder="mot">mot</p><p alt="mot">mot</p><p something="word">mot</p></div>'
|
||||||
);
|
);
|
||||||
|
snapshotApp(app);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("can set translatable attributes", async () => {
|
test("can set translatable attributes", async () => {
|
||||||
@@ -66,11 +82,16 @@ describe("translation support", () => {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
await mount(SomeComponent, fixture, {
|
const app = new App(SomeComponent);
|
||||||
|
app.configure({
|
||||||
translateFn: (expr: string) => (expr === "word" ? "mot" : expr),
|
translateFn: (expr: string) => (expr === "word" ? "mot" : expr),
|
||||||
translatableAttributes: ["potato"],
|
translatableAttributes: ["potato"],
|
||||||
});
|
});
|
||||||
expect(fixture.innerHTML).toBe('<div tomato="word" potato="mot" title="word">text</div>');
|
const comp = await app.mount(fixture);
|
||||||
|
|
||||||
|
const el = comp.el as HTMLElement;
|
||||||
|
expect(el.outerHTML).toBe('<div tomato="word" potato="mot" title="word">text</div>');
|
||||||
|
snapshotApp(app);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("translation is done on the trimmed text, with extra spaces readded after", async () => {
|
test("translation is done on the trimmed text, with extra spaces readded after", async () => {
|
||||||
@@ -82,8 +103,14 @@ describe("translation support", () => {
|
|||||||
|
|
||||||
const translateFn = jest.fn((expr: string) => (expr === "word" ? "mot" : expr));
|
const translateFn = jest.fn((expr: string) => (expr === "word" ? "mot" : expr));
|
||||||
|
|
||||||
await mount(SomeComponent, fixture, { translateFn });
|
const app = new App(SomeComponent);
|
||||||
expect(fixture.innerHTML).toBe("<div> mot </div>");
|
app.configure({ translateFn });
|
||||||
|
const comp = await app.mount(fixture);
|
||||||
|
|
||||||
|
const el = comp.el as HTMLElement;
|
||||||
|
|
||||||
|
expect(el.outerHTML).toBe("<div> mot </div>");
|
||||||
expect(translateFn).toHaveBeenCalledWith("word");
|
expect(translateFn).toHaveBeenCalledWith("word");
|
||||||
|
snapshotApp(app);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { TemplateSet } from "../../src/app/template_set";
|
import { TemplateSet } from "../../src/app/template_set";
|
||||||
import { renderToString, snapshotTemplate, TestContext } from "../helpers";
|
import { renderToString, TestContext, compile } from "../helpers";
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// basic validation
|
// basic validation
|
||||||
@@ -21,7 +21,7 @@ describe("basic validation", () => {
|
|||||||
|
|
||||||
test("invalid xml", () => {
|
test("invalid xml", () => {
|
||||||
const template = "<div>";
|
const template = "<div>";
|
||||||
expect(() => snapshotTemplate(template)).toThrow("Invalid XML in template");
|
expect(() => compile(template)).toThrow("Invalid XML in template");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("missing template in template set", () => {
|
test("missing template in template set", () => {
|
||||||
|
|||||||
@@ -39,10 +39,4 @@ describe("white space handling", () => {
|
|||||||
</pre>`;
|
</pre>`;
|
||||||
expect(renderToString(template3)).toBe(template3);
|
expect(renderToString(template3)).toBe(template3);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("pre inside a div with a new line", () => {
|
|
||||||
expect(renderToString(`<div><pre>SomeText</pre>\n</div>`)).toBe(
|
|
||||||
"<div><pre>SomeText</pre></div>"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`app destroy remove the widget from the DOM 1`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return block1();
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -3,23 +3,8 @@
|
|||||||
exports[`event handling handler receive the event as argument 1`] = `
|
exports[`event handling handler receive the event as argument 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<span block-handler-0=\\"click\\"><block-child-0/><block-text-1/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let hdlr1 = [ctx['inc'], ctx];
|
|
||||||
let b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
|
||||||
let txt1 = ctx['state'].value;
|
|
||||||
return block1([hdlr1, txt1], [b2]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`event handling handler receive the event as argument 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>simple vnode</div>\`);
|
let block1 = createBlock(\`<div>simple vnode</div>\`);
|
||||||
|
|
||||||
@@ -29,11 +14,28 @@ exports[`event handling handler receive the event as argument 2`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`event handling handler receive the event as argument 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span block-handler-0=\\"click\\"><block-child-0/><block-text-1/></span>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = [ctx['inc'], ctx];
|
||||||
|
let b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
||||||
|
let d2 = ctx['state'].value;
|
||||||
|
return block1([d1, d2], [b2]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`event handling objects from scope are properly captured by t-on 1`] = `
|
exports[`event handling objects from scope are properly captured by t-on 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block3 = createBlock(\`<div class=\\"item\\" block-handler-0=\\"click\\"/>\`);
|
let block3 = createBlock(\`<div class=\\"item\\" block-handler-0=\\"click\\"/>\`);
|
||||||
@@ -46,8 +48,8 @@ exports[`event handling objects from scope are properly captured by t-on 1`] = `
|
|||||||
let key1 = ctx['item'];
|
let key1 = ctx['item'];
|
||||||
const v1 = ctx['onClick'];
|
const v1 = ctx['onClick'];
|
||||||
const v2 = ctx['item'];
|
const v2 = ctx['item'];
|
||||||
let hdlr1 = [ev=>v1(v2.val,ev), ctx];
|
let d1 = [ev=>v1(v2.val,ev), ctx];
|
||||||
c_block2[i1] = withKey(block3([hdlr1]), key1);
|
c_block2[i1] = withKey(block3([d1]), key1);
|
||||||
}
|
}
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
@@ -58,14 +60,15 @@ exports[`event handling objects from scope are properly captured by t-on 1`] = `
|
|||||||
exports[`event handling support for callable expression in event handler 1`] = `
|
exports[`event handling support for callable expression in event handler 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/><input type=\\"text\\" block-handler-1=\\"input\\"/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/><input type=\\"text\\" block-handler-1=\\"input\\"/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['state'].value;
|
let d1 = ctx['state'].value;
|
||||||
let hdlr1 = [ctx['obj'].onInput, ctx];
|
let d2 = [ctx['obj'].onInput, ctx];
|
||||||
return block1([txt1, hdlr1]);
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -73,8 +76,8 @@ exports[`event handling support for callable expression in event handler 1`] = `
|
|||||||
exports[`event handling t-on with handler bound to dynamic argument on a t-foreach 1`] = `
|
exports[`event handling t-on with handler bound to dynamic argument on a t-foreach 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block3 = createBlock(\`<div class=\\"item\\" block-handler-0=\\"click\\"/>\`);
|
let block3 = createBlock(\`<div class=\\"item\\" block-handler-0=\\"click\\"/>\`);
|
||||||
@@ -87,8 +90,8 @@ exports[`event handling t-on with handler bound to dynamic argument on a t-forea
|
|||||||
let key1 = ctx['item'];
|
let key1 = ctx['item'];
|
||||||
const v1 = ctx['onClick'];
|
const v1 = ctx['onClick'];
|
||||||
const v2 = ctx['item'];
|
const v2 = ctx['item'];
|
||||||
let hdlr1 = [ev=>v1(v2,ev), ctx];
|
let d1 = [ev=>v1(v2,ev), ctx];
|
||||||
c_block2[i1] = withKey(block3([hdlr1]), key1);
|
c_block2[i1] = withKey(block3([d1]), key1);
|
||||||
}
|
}
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
|
|||||||
@@ -3,10 +3,14 @@
|
|||||||
exports[`basics basic use 1`] = `
|
exports[`basics basic use 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span>child<block-text-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`Child\`, {p: 1}, key + \`__1\`, node, ctx);
|
let d1 = ctx['props'].p;
|
||||||
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -14,13 +18,11 @@ exports[`basics basic use 1`] = `
|
|||||||
exports[`basics basic use 2`] = `
|
exports[`basics basic use 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<span>child<block-text-0/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].p;
|
return component(\`Child\`, {p: 1}, key + \`__1\`, node, ctx);
|
||||||
return block1([txt1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -28,7 +30,36 @@ exports[`basics basic use 2`] = `
|
|||||||
exports[`basics can select a sub widget 1`] = `
|
exports[`basics can select a sub widget 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span>CHILD 1</span>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return block1();
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`basics can select a sub widget 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div>CHILD 2</div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return block1();
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`basics can select a sub widget 3`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2,b3;
|
let b2,b3;
|
||||||
@@ -43,10 +74,11 @@ exports[`basics can select a sub widget 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`basics can select a sub widget 2`] = `
|
exports[`basics can select a sub widget, part 2 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span>CHILD 1</span>\`);
|
let block1 = createBlock(\`<span>CHILD 1</span>\`);
|
||||||
|
|
||||||
@@ -56,10 +88,11 @@ exports[`basics can select a sub widget 2`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`basics can select a sub widget 3`] = `
|
exports[`basics can select a sub widget, part 2 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>CHILD 2</div>\`);
|
let block1 = createBlock(\`<div>CHILD 2</div>\`);
|
||||||
|
|
||||||
@@ -69,10 +102,11 @@ exports[`basics can select a sub widget 3`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`basics can select a sub widget, part 2 1`] = `
|
exports[`basics can select a sub widget, part 2 3`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2,b3;
|
let b2,b3;
|
||||||
@@ -87,39 +121,18 @@ exports[`basics can select a sub widget, part 2 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`basics can select a sub widget, part 2 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<span>CHILD 1</span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return block1();
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`basics can select a sub widget, part 2 3`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>CHILD 2</div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return block1();
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`basics sub widget is interactive 1`] = `
|
exports[`basics sub widget is interactive 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span><button block-handler-0=\\"click\\">click</button>child<block-text-1/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`Child\`, {p: 1}, key + \`__1\`, node, ctx);
|
let d1 = [ctx['inc'], ctx];
|
||||||
|
let d2 = ctx['state'].val;
|
||||||
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -127,14 +140,11 @@ exports[`basics sub widget is interactive 1`] = `
|
|||||||
exports[`basics sub widget is interactive 2`] = `
|
exports[`basics sub widget is interactive 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<span><button block-handler-0=\\"click\\">click</button>child<block-text-1/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [ctx['inc'], ctx];
|
return component(\`Child\`, {p: 1}, key + \`__1\`, node, ctx);
|
||||||
let txt1 = ctx['state'].val;
|
|
||||||
return block1([hdlr1, txt1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -142,13 +152,13 @@ exports[`basics sub widget is interactive 2`] = `
|
|||||||
exports[`basics top level sub widget with a parent 1`] = `
|
exports[`basics top level sub widget with a parent 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<span>Hello</span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = component(\`ComponentB\`, {}, key + \`__1\`, node, ctx);
|
return block1();
|
||||||
return block1([], [b2]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -156,7 +166,8 @@ exports[`basics top level sub widget with a parent 1`] = `
|
|||||||
exports[`basics top level sub widget with a parent 2`] = `
|
exports[`basics top level sub widget with a parent 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`ComponentC\`, {}, key + \`__1\`, node, ctx);
|
return component(\`ComponentC\`, {}, key + \`__1\`, node, ctx);
|
||||||
@@ -167,12 +178,14 @@ exports[`basics top level sub widget with a parent 2`] = `
|
|||||||
exports[`basics top level sub widget with a parent 3`] = `
|
exports[`basics top level sub widget with a parent 3`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span>Hello</span>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return block1();
|
let b2 = component(\`ComponentB\`, {}, key + \`__1\`, node, ctx);
|
||||||
|
return block1([], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -3,20 +3,21 @@
|
|||||||
exports[`hooks autofocus hook input in a t-if 1`] = `
|
exports[`hooks autofocus hook input in a t-if 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><input block-ref=\\"0\\"/><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><input block-ref=\\"0\\"/><block-child-0/></div>\`);
|
||||||
let block2 = createBlock(\`<input block-ref=\\"0\\"/>\`);
|
let block2 = createBlock(\`<input block-ref=\\"0\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const refs = ctx.__owl__.refs;
|
const refs = ctx.__owl__.refs;
|
||||||
const ref1 = (el) => refs[\`input1\`] = el;
|
|
||||||
const ref2 = (el) => refs[\`input2\`] = el;
|
|
||||||
let b2;
|
let b2;
|
||||||
|
let d1 = (el) => refs[\`input1\`] = el;
|
||||||
if (ctx['state'].flag) {
|
if (ctx['state'].flag) {
|
||||||
b2 = block2([ref2]);
|
let d2 = (el) => refs[\`input2\`] = el;
|
||||||
|
b2 = block2([d2]);
|
||||||
}
|
}
|
||||||
return block1([ref1], [b2]);
|
return block1([d1], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -24,15 +25,16 @@ exports[`hooks autofocus hook input in a t-if 1`] = `
|
|||||||
exports[`hooks autofocus hook simple input 1`] = `
|
exports[`hooks autofocus hook simple input 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><input block-ref=\\"0\\"/><input block-ref=\\"1\\"/></div>\`);
|
let block1 = createBlock(\`<div><input block-ref=\\"0\\"/><input block-ref=\\"1\\"/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const refs = ctx.__owl__.refs;
|
const refs = ctx.__owl__.refs;
|
||||||
const ref1 = (el) => refs[\`input1\`] = el;
|
let d1 = (el) => refs[\`input1\`] = el;
|
||||||
const ref2 = (el) => refs[\`input2\`] = el;
|
let d2 = (el) => refs[\`input2\`] = el;
|
||||||
return block1([ref1, ref2]);
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -40,10 +42,14 @@ exports[`hooks autofocus hook simple input 1`] = `
|
|||||||
exports[`hooks can use onWillStart, onWillUpdateProps 1`] = `
|
exports[`hooks can use onWillStart, onWillUpdateProps 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`MyComponent\`, {value: ctx['state'].value}, key + \`__1\`, node, ctx);
|
let d1 = ctx['props'].value;
|
||||||
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -51,13 +57,11 @@ exports[`hooks can use onWillStart, onWillUpdateProps 1`] = `
|
|||||||
exports[`hooks can use onWillStart, onWillUpdateProps 2`] = `
|
exports[`hooks can use onWillStart, onWillUpdateProps 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].value;
|
return component(\`MyComponent\`, {value: ctx['state'].value}, key + \`__1\`, node, ctx);
|
||||||
return block1([txt1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -65,7 +69,8 @@ exports[`hooks can use onWillStart, onWillUpdateProps 2`] = `
|
|||||||
exports[`hooks can use useComponent 1`] = `
|
exports[`hooks can use useComponent 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
@@ -78,13 +83,14 @@ exports[`hooks can use useComponent 1`] = `
|
|||||||
exports[`hooks can use useEnv 1`] = `
|
exports[`hooks can use useEnv 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['env'].val;
|
let d1 = ctx['env'].val;
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -92,13 +98,14 @@ exports[`hooks can use useEnv 1`] = `
|
|||||||
exports[`hooks mounted callbacks should be called in reverse order from willUnmount callbacks 1`] = `
|
exports[`hooks mounted callbacks should be called in reverse order from willUnmount callbacks 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>hey<block-text-0/></div>\`);
|
let block1 = createBlock(\`<div>hey<block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['state'].value;
|
let d1 = ctx['state'].value;
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -106,7 +113,23 @@ exports[`hooks mounted callbacks should be called in reverse order from willUnmo
|
|||||||
exports[`hooks parent and child env 1`] = `
|
exports[`hooks parent and child env 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['env'].val;
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`hooks parent and child env 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = text(ctx['env'].val);
|
let b2 = text(ctx['env'].val);
|
||||||
@@ -116,30 +139,17 @@ exports[`hooks parent and child env 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`hooks parent and child env 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['env'].val;
|
|
||||||
return block1([txt1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`hooks two different call to willPatch/patched should work 1`] = `
|
exports[`hooks two different call to willPatch/patched should work 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>hey<block-text-0/></div>\`);
|
let block1 = createBlock(\`<div>hey<block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['state'].value;
|
let d1 = ctx['state'].value;
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -147,39 +157,14 @@ exports[`hooks two different call to willPatch/patched should work 1`] = `
|
|||||||
exports[`hooks use sub env does not pollute user env 1`] = `
|
exports[`hooks use sub env does not pollute user env 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['env'].val;
|
let d1 = ctx['env'].val;
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`hooks use sub env supports arbitrary descriptor 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`hooks use sub env supports arbitrary descriptor 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/> <block-text-1/></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['env'].someVal;
|
|
||||||
let txt2 = ctx['env'].someVal2;
|
|
||||||
return block1([txt1, txt2]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -187,7 +172,8 @@ exports[`hooks use sub env supports arbitrary descriptor 2`] = `
|
|||||||
exports[`hooks useEffect hook dependencies prevent effects from rerunning when unchanged 1`] = `
|
exports[`hooks useEffect hook dependencies prevent effects from rerunning when unchanged 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
@@ -197,29 +183,11 @@ exports[`hooks useEffect hook dependencies prevent effects from rerunning when u
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`hooks useEffect hook effect can depend on stuff in dom 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block2 = createBlock(\`<div block-ref=\\"0\\"/>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
const refs = ctx.__owl__.refs;
|
|
||||||
const ref1 = (el) => refs[\`div\`] = el;
|
|
||||||
let b2;
|
|
||||||
if (ctx['state'].value) {
|
|
||||||
b2 = block2([ref1]);
|
|
||||||
}
|
|
||||||
return multi([b2]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`hooks useEffect hook effect runs on mount, is reapplied on patch, and is cleaned up on unmount and before reapplying 1`] = `
|
exports[`hooks useEffect hook effect runs on mount, is reapplied on patch, and is cleaned up on unmount and before reapplying 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
@@ -232,13 +200,14 @@ exports[`hooks useEffect hook effect runs on mount, is reapplied on patch, and i
|
|||||||
exports[`hooks useEffect hook effect with empty dependency list never reruns 1`] = `
|
exports[`hooks useEffect hook effect with empty dependency list never reruns 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['state'].value;
|
let d1 = ctx['state'].value;
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -246,7 +215,23 @@ exports[`hooks useEffect hook effect with empty dependency list never reruns 1`]
|
|||||||
exports[`hooks useExternalListener 1`] = `
|
exports[`hooks useExternalListener 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['props'].value;
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`hooks useExternalListener 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2;
|
let b2;
|
||||||
@@ -258,32 +243,19 @@ exports[`hooks useExternalListener 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`hooks useExternalListener 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['props'].value;
|
|
||||||
return block1([txt1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`hooks useRef hook: basic use 1`] = `
|
exports[`hooks useRef hook: basic use 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><button block-ref=\\"0\\"><block-text-1/></button></div>\`);
|
let block1 = createBlock(\`<div><button block-ref=\\"0\\"><block-text-1/></button></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const refs = ctx.__owl__.refs;
|
const refs = ctx.__owl__.refs;
|
||||||
const ref1 = (el) => refs[\`button\`] = el;
|
let d1 = (el) => refs[\`button\`] = el;
|
||||||
let txt1 = ctx['value'];
|
let d2 = ctx['value'];
|
||||||
return block1([ref1, txt1]);
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
exports[`lifecycle hooks basic checks for a component 1`] = `
|
exports[`lifecycle hooks basic checks for a component 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span>test</span>\`);
|
let block1 = createBlock(\`<span>test</span>\`);
|
||||||
|
|
||||||
@@ -16,14 +17,13 @@ exports[`lifecycle hooks basic checks for a component 1`] = `
|
|||||||
exports[`lifecycle hooks component semantics 1`] = `
|
exports[`lifecycle hooks component semantics 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>A<block-child-0/><block-child-1/></div>\`);
|
let block1 = createBlock(\`<div>B</div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = component(\`B\`, {}, key + \`__1\`, node, ctx);
|
return block1();
|
||||||
let b3 = component(\`C\`, {}, key + \`__2\`, node, ctx);
|
|
||||||
return block1([], [b2, b3]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -31,9 +31,10 @@ exports[`lifecycle hooks component semantics 1`] = `
|
|||||||
exports[`lifecycle hooks component semantics 2`] = `
|
exports[`lifecycle hooks component semantics 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>B</div>\`);
|
let block1 = createBlock(\`<div>D</div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return block1();
|
return block1();
|
||||||
@@ -44,7 +45,36 @@ exports[`lifecycle hooks component semantics 2`] = `
|
|||||||
exports[`lifecycle hooks component semantics 3`] = `
|
exports[`lifecycle hooks component semantics 3`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div>E</div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return block1();
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`lifecycle hooks component semantics 4`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div>F</div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return block1();
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`lifecycle hooks component semantics 5`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>C<block-child-0/><block-child-1/><block-child-2/></div>\`);
|
let block1 = createBlock(\`<div>C<block-child-0/><block-child-1/><block-child-2/></div>\`);
|
||||||
|
|
||||||
@@ -61,38 +91,29 @@ exports[`lifecycle hooks component semantics 3`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks component semantics 4`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>D</div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return block1();
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`lifecycle hooks component semantics 5`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>E</div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return block1();
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`lifecycle hooks component semantics 6`] = `
|
exports[`lifecycle hooks component semantics 6`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>F</div>\`);
|
let block1 = createBlock(\`<div>A<block-child-0/><block-child-1/></div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let b2 = component(\`B\`, {}, key + \`__1\`, node, ctx);
|
||||||
|
let b3 = component(\`C\`, {}, key + \`__2\`, node, ctx);
|
||||||
|
return block1([], [b2, b3]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`lifecycle hooks components are unmounted and destroyed if no longer in DOM 1`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return block1();
|
return block1();
|
||||||
@@ -100,10 +121,42 @@ exports[`lifecycle hooks component semantics 6`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`lifecycle hooks components are unmounted and destroyed if no longer in DOM 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let b2;
|
||||||
|
if (ctx['state'].ok) {
|
||||||
|
b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
||||||
|
}
|
||||||
|
return multi([b2]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks components are unmounted and destroyed if no longer in DOM, even after updateprops 1`] = `
|
exports[`lifecycle hooks components are unmounted and destroyed if no longer in DOM, even after updateprops 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['props'].n;
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`lifecycle hooks components are unmounted and destroyed if no longer in DOM, even after updateprops 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block2 = createBlock(\`<div><block-child-0/></div>\`);
|
let block2 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -118,39 +171,11 @@ exports[`lifecycle hooks components are unmounted and destroyed if no longer in
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks components are unmounted and destroyed if no longer in DOM, even after updateprops 2`] = `
|
exports[`lifecycle hooks hooks are called in proper order in widget creation/destruction 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['props'].n;
|
|
||||||
return block1([txt1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`lifecycle hooks components are unmounted destroyed if no longer in DOM 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let b2;
|
|
||||||
if (ctx['state'].ok) {
|
|
||||||
b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
|
||||||
return multi([b2]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`lifecycle hooks components are unmounted destroyed if no longer in DOM 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
@@ -160,10 +185,11 @@ exports[`lifecycle hooks components are unmounted destroyed if no longer in DOM
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks hooks are called in proper order in widget creation/destruction 1`] = `
|
exports[`lifecycle hooks hooks are called in proper order in widget creation/destruction 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -174,10 +200,11 @@ exports[`lifecycle hooks hooks are called in proper order in widget creation/des
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks hooks are called in proper order in widget creation/destruction 2`] = `
|
exports[`lifecycle hooks lifecycle semantics 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
@@ -187,10 +214,11 @@ exports[`lifecycle hooks hooks are called in proper order in widget creation/des
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks lifecycle semantics 1`] = `
|
exports[`lifecycle hooks lifecycle semantics 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -201,10 +229,11 @@ exports[`lifecycle hooks lifecycle semantics 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks lifecycle semantics 2`] = `
|
exports[`lifecycle hooks lifecycle semantics, part 2 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
@@ -214,10 +243,23 @@ exports[`lifecycle hooks lifecycle semantics 2`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks lifecycle semantics, part 2 1`] = `
|
exports[`lifecycle hooks lifecycle semantics, part 2 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return component(\`GrandChild\`, {}, key + \`__1\`, node, ctx);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`lifecycle hooks lifecycle semantics, part 2 3`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2;
|
let b2;
|
||||||
@@ -229,21 +271,11 @@ exports[`lifecycle hooks lifecycle semantics, part 2 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks lifecycle semantics, part 2 2`] = `
|
exports[`lifecycle hooks lifecycle semantics, part 3 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return component(\`GrandChild\`, {}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`lifecycle hooks lifecycle semantics, part 2 3`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
@@ -253,10 +285,23 @@ exports[`lifecycle hooks lifecycle semantics, part 2 3`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks lifecycle semantics, part 3 1`] = `
|
exports[`lifecycle hooks lifecycle semantics, part 3 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return component(\`GrandChild\`, {}, key + \`__1\`, node, ctx);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`lifecycle hooks lifecycle semantics, part 3 3`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2;
|
let b2;
|
||||||
@@ -271,14 +316,13 @@ exports[`lifecycle hooks lifecycle semantics, part 3 1`] = `
|
|||||||
exports[`lifecycle hooks lifecycle semantics, part 4 1`] = `
|
exports[`lifecycle hooks lifecycle semantics, part 4 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2;
|
return block1();
|
||||||
if (ctx['state'].hasChild) {
|
|
||||||
b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
|
||||||
return multi([b2]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -286,7 +330,8 @@ exports[`lifecycle hooks lifecycle semantics, part 4 1`] = `
|
|||||||
exports[`lifecycle hooks lifecycle semantics, part 4 2`] = `
|
exports[`lifecycle hooks lifecycle semantics, part 4 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`GrandChild\`, {}, key + \`__1\`, node, ctx);
|
return component(\`GrandChild\`, {}, key + \`__1\`, node, ctx);
|
||||||
@@ -297,20 +342,8 @@ exports[`lifecycle hooks lifecycle semantics, part 4 2`] = `
|
|||||||
exports[`lifecycle hooks lifecycle semantics, part 4 3`] = `
|
exports[`lifecycle hooks lifecycle semantics, part 4 3`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<div/>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return block1();
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`lifecycle hooks lifecycle semantics, part 5 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2;
|
let b2;
|
||||||
@@ -322,10 +355,11 @@ exports[`lifecycle hooks lifecycle semantics, part 5 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks lifecycle semantics, part 5 2`] = `
|
exports[`lifecycle hooks lifecycle semantics, part 5 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
@@ -335,21 +369,27 @@ exports[`lifecycle hooks lifecycle semantics, part 5 2`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`lifecycle hooks lifecycle semantics, part 5 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let b2;
|
||||||
|
if (ctx['state'].hasChild) {
|
||||||
|
b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
||||||
|
}
|
||||||
|
return multi([b2]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks lifecycle semantics, part 6 1`] = `
|
exports[`lifecycle hooks lifecycle semantics, part 6 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return component(\`Child\`, {value: ctx['state'].value}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`lifecycle hooks lifecycle semantics, part 6 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
@@ -359,10 +399,23 @@ exports[`lifecycle hooks lifecycle semantics, part 6 2`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`lifecycle hooks lifecycle semantics, part 6 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return component(\`Child\`, {value: ctx['state'].value}, key + \`__1\`, node, ctx);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks mounted hook is called if mounted in DOM 1`] = `
|
exports[`lifecycle hooks mounted hook is called if mounted in DOM 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
@@ -375,7 +428,22 @@ exports[`lifecycle hooks mounted hook is called if mounted in DOM 1`] = `
|
|||||||
exports[`lifecycle hooks mounted hook is called on every mount, not just the first one 1`] = `
|
exports[`lifecycle hooks mounted hook is called on every mount, not just the first one 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div>child</div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return block1();
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`lifecycle hooks mounted hook is called on every mount, not just the first one 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2;
|
let b2;
|
||||||
@@ -387,12 +455,13 @@ exports[`lifecycle hooks mounted hook is called on every mount, not just the fir
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks mounted hook is called on every mount, not just the first one 2`] = `
|
exports[`lifecycle hooks mounted hook is called on subcomponents, in proper order 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>child</div>\`);
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return block1();
|
return block1();
|
||||||
@@ -400,10 +469,11 @@ exports[`lifecycle hooks mounted hook is called on every mount, not just the fir
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks mounted hook is called on subcomponents, in proper order 1`] = `
|
exports[`lifecycle hooks mounted hook is called on subcomponents, in proper order 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -414,10 +484,11 @@ exports[`lifecycle hooks mounted hook is called on subcomponents, in proper orde
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks mounted hook is called on subcomponents, in proper order 2`] = `
|
exports[`lifecycle hooks mounted hook is called on subsubcomponents, in proper order 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
@@ -427,27 +498,11 @@ exports[`lifecycle hooks mounted hook is called on subcomponents, in proper orde
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks mounted hook is called on subsubcomponents, in proper order 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let b2;
|
|
||||||
if (ctx['state'].flag) {
|
|
||||||
b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
|
||||||
return block1([], [b2]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`lifecycle hooks mounted hook is called on subsubcomponents, in proper order 2`] = `
|
exports[`lifecycle hooks mounted hook is called on subsubcomponents, in proper order 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -461,7 +516,54 @@ exports[`lifecycle hooks mounted hook is called on subsubcomponents, in proper o
|
|||||||
exports[`lifecycle hooks mounted hook is called on subsubcomponents, in proper order 3`] = `
|
exports[`lifecycle hooks mounted hook is called on subsubcomponents, in proper order 3`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let b2;
|
||||||
|
if (ctx['state'].flag) {
|
||||||
|
b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
||||||
|
}
|
||||||
|
return block1([], [b2]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`lifecycle hooks onWillRender 1`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\"><block-text-1/></button>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = [ctx['increment'], ctx];
|
||||||
|
let d2 = ctx['state'].value;
|
||||||
|
return block1([d1, d2]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`lifecycle hooks onWillRender 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`lifecycle hooks patched hook is called after updateProps 1`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
@@ -471,36 +573,11 @@ exports[`lifecycle hooks mounted hook is called on subsubcomponents, in proper o
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks onWillRender 1`] = `
|
exports[`lifecycle hooks patched hook is called after updateProps 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`lifecycle hooks onWillRender 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<button block-handler-0=\\"click\\"><block-text-1/></button>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let hdlr1 = [ctx['increment'], ctx];
|
|
||||||
let txt1 = ctx['state'].value;
|
|
||||||
return block1([hdlr1, txt1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`lifecycle hooks patched hook is called after updateProps 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -511,10 +588,26 @@ exports[`lifecycle hooks patched hook is called after updateProps 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks patched hook is called after updateProps 2`] = `
|
exports[`lifecycle hooks patched hook is called after updating State 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['state'].a;
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`lifecycle hooks sub widget (inside sub node): hooks are correctly called 1`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
@@ -524,66 +617,11 @@ exports[`lifecycle hooks patched hook is called after updateProps 2`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks patched hook is called after updating State 1`] = `
|
exports[`lifecycle hooks sub widget (inside sub node): hooks are correctly called 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['state'].a;
|
|
||||||
return block1([txt1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`lifecycle hooks render in mounted 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['patched'];
|
|
||||||
return block1([txt1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`lifecycle hooks render in patched 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['patched'];
|
|
||||||
return block1([txt1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`lifecycle hooks render in willPatch 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['patched'];
|
|
||||||
return block1([txt1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`lifecycle hooks sub widget (inside sub node): hooks are correctly called 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2;
|
let b2;
|
||||||
@@ -595,29 +633,17 @@ exports[`lifecycle hooks sub widget (inside sub node): hooks are correctly calle
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks sub widget (inside sub node): hooks are correctly called 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return block1();
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`lifecycle hooks willPatch, patched hook are called on subsubcomponents, in proper order 1`] = `
|
exports[`lifecycle hooks willPatch, patched hook are called on subsubcomponents, in proper order 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = component(\`Child\`, {n: ctx['state'].n}, key + \`__1\`, node, ctx);
|
let d1 = ctx['props'].n;
|
||||||
return block1([], [b2]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -625,7 +651,8 @@ exports[`lifecycle hooks willPatch, patched hook are called on subsubcomponents,
|
|||||||
exports[`lifecycle hooks willPatch, patched hook are called on subsubcomponents, in proper order 2`] = `
|
exports[`lifecycle hooks willPatch, patched hook are called on subsubcomponents, in proper order 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -639,13 +666,14 @@ exports[`lifecycle hooks willPatch, patched hook are called on subsubcomponents,
|
|||||||
exports[`lifecycle hooks willPatch, patched hook are called on subsubcomponents, in proper order 3`] = `
|
exports[`lifecycle hooks willPatch, patched hook are called on subsubcomponents, in proper order 3`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].n;
|
let b2 = component(\`Child\`, {n: ctx['state'].n}, key + \`__1\`, node, ctx);
|
||||||
return block1([txt1]);
|
return block1([], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -653,18 +681,8 @@ exports[`lifecycle hooks willPatch, patched hook are called on subsubcomponents,
|
|||||||
exports[`lifecycle hooks willStart hook is called on sub component 1`] = `
|
exports[`lifecycle hooks willStart hook is called on sub component 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`lifecycle hooks willStart hook is called on sub component 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
@@ -674,10 +692,23 @@ exports[`lifecycle hooks willStart hook is called on sub component 2`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`lifecycle hooks willStart hook is called on sub component 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks willStart is called 1`] = `
|
exports[`lifecycle hooks willStart is called 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span>simple vnode</span>\`);
|
let block1 = createBlock(\`<span>simple vnode</span>\`);
|
||||||
|
|
||||||
@@ -690,7 +721,8 @@ exports[`lifecycle hooks willStart is called 1`] = `
|
|||||||
exports[`lifecycle hooks willStart is called with component as this 1`] = `
|
exports[`lifecycle hooks willStart is called with component as this 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span>simple vnode</span>\`);
|
let block1 = createBlock(\`<span>simple vnode</span>\`);
|
||||||
|
|
||||||
@@ -703,7 +735,22 @@ exports[`lifecycle hooks willStart is called with component as this 1`] = `
|
|||||||
exports[`lifecycle hooks willStart, mounted on subwidget rendered after main is mounted in some other position 1`] = `
|
exports[`lifecycle hooks willStart, mounted on subwidget rendered after main is mounted in some other position 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return block1();
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`lifecycle hooks willStart, mounted on subwidget rendered after main is mounted in some other position 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
||||||
let block3 = createBlock(\`<div/>\`);
|
let block3 = createBlock(\`<div/>\`);
|
||||||
@@ -720,26 +767,17 @@ exports[`lifecycle hooks willStart, mounted on subwidget rendered after main is
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`lifecycle hooks willStart, mounted on subwidget rendered after main is mounted in some other position 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return block1();
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`lifecycle hooks willUpdateProps hook is called 1`] = `
|
exports[`lifecycle hooks willUpdateProps hook is called 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`Child\`, {n: ctx['state'].n}, key + \`__1\`, node, ctx);
|
let d1 = ctx['props'].n;
|
||||||
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -747,13 +785,11 @@ exports[`lifecycle hooks willUpdateProps hook is called 1`] = `
|
|||||||
exports[`lifecycle hooks willUpdateProps hook is called 2`] = `
|
exports[`lifecycle hooks willUpdateProps hook is called 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].n;
|
return component(\`Child\`, {n: ctx['state'].n}, key + \`__1\`, node, ctx);
|
||||||
return block1([txt1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -3,7 +3,23 @@
|
|||||||
exports[`basics accept ES6-like syntax for props (with getters) 1`] = `
|
exports[`basics accept ES6-like syntax for props (with getters) 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['props'].greetings;
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`basics accept ES6-like syntax for props (with getters) 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -14,25 +30,26 @@ exports[`basics accept ES6-like syntax for props (with getters) 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`basics accept ES6-like syntax for props (with getters) 2`] = `
|
exports[`basics arrow functions as prop correctly capture their scope 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].greetings;
|
let d1 = [ctx['props'].onClick, ctx];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`basics arrow functions as prop correctly capture their scope 1`] = `
|
exports[`basics arrow functions as prop correctly capture their scope 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
@@ -42,31 +59,33 @@ exports[`basics arrow functions as prop correctly capture their scope 1`] = `
|
|||||||
let key1 = ctx['item'].val;
|
let key1 = ctx['item'].val;
|
||||||
const v1 = ctx['onClick'];
|
const v1 = ctx['onClick'];
|
||||||
const v2 = ctx['item'];
|
const v2 = ctx['item'];
|
||||||
c_block1[i1] = withKey(component(\`Child\`, {onClick: ev=>v1(v2.val,ev)}, key + \`__1__\${key1}\`, node, ctx), key1);
|
c_block1[i1] = withKey(component(\`Child\`, {onClick: ev=>v1(v2.val,ev)}, key + \`__3__\${key1}\`, node, ctx), key1);
|
||||||
}
|
}
|
||||||
return list(c_block1);
|
return list(c_block1);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`basics arrow functions as prop correctly capture their scope 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<button block-handler-0=\\"click\\"/>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let hdlr1 = [ctx['props'].onClick, ctx];
|
|
||||||
return block1([hdlr1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`basics explicit object prop 1`] = `
|
exports[`basics explicit object prop 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['state'].someval;
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`basics explicit object prop 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -77,27 +96,17 @@ exports[`basics explicit object prop 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`basics explicit object prop 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['state'].someval;
|
|
||||||
return block1([txt1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`basics prop names can contain - 1`] = `
|
exports[`basics prop names can contain - 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`Child\`, {'prop-name': 7}, key + \`__1\`, node, ctx);
|
let d1 = ctx['props']['prop-name'];
|
||||||
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -105,13 +114,11 @@ exports[`basics prop names can contain - 1`] = `
|
|||||||
exports[`basics prop names can contain - 2`] = `
|
exports[`basics prop names can contain - 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props']['prop-name'];
|
return component(\`Child\`, {'prop-name': 7}, key + \`__1\`, node, ctx);
|
||||||
return block1([txt1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -119,10 +126,14 @@ exports[`basics prop names can contain - 2`] = `
|
|||||||
exports[`basics support prop names that aren't valid bare object property names 1`] = `
|
exports[`basics support prop names that aren't valid bare object property names 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<button block-handler-0=\\"click\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`Child\`, {'some-dashed-prop': 5,'a.b': 'keyword prop'}, key + \`__1\`, node, ctx);
|
let d1 = [ctx['props'].onClick, ctx];
|
||||||
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -130,13 +141,11 @@ exports[`basics support prop names that aren't valid bare object property names
|
|||||||
exports[`basics support prop names that aren't valid bare object property names 2`] = `
|
exports[`basics support prop names that aren't valid bare object property names 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<button block-handler-0=\\"click\\"/>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [ctx['props'].onClick, ctx];
|
return component(\`Child\`, {'some-dashed-prop': 5,'a.b': 'keyword prop'}, key + \`__1\`, node, ctx);
|
||||||
return block1([hdlr1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -144,22 +153,15 @@ exports[`basics support prop names that aren't valid bare object property names
|
|||||||
exports[`basics t-set with a body expression can be passed in props, and then t-out 1`] = `
|
exports[`basics t-set with a body expression can be passed in props, and then t-out 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, LazyValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<span><block-text-0/><block-child-0/></span>\`);
|
||||||
let block2 = createBlock(\`<p>43</p>\`);
|
|
||||||
|
|
||||||
function value1(ctx, node, key = \\"\\") {
|
|
||||||
return block2();
|
|
||||||
}
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
let d1 = ctx['props'].val;
|
||||||
ctx[isBoundary] = 1
|
let b2 = safeOutput(ctx['props'].val);
|
||||||
ctx[\`abc\`] = new LazyValue(value1, ctx, node);
|
return block1([d1], [b2]);
|
||||||
let b3 = component(\`Child\`, {val: ctx['abc']}, key + \`__1\`, node, ctx);
|
|
||||||
return block1([], [b3]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -167,15 +169,19 @@ exports[`basics t-set with a body expression can be passed in props, and then t-
|
|||||||
exports[`basics t-set with a body expression can be passed in props, and then t-out 2`] = `
|
exports[`basics t-set with a body expression can be passed in props, and then t-out 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { safeOutput } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/><block-child-0/></span>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
let block2 = createBlock(\`<p>43</p>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].val;
|
ctx = Object.create(ctx);
|
||||||
let b2 = safeOutput(ctx['props'].val);
|
ctx[isBoundary] = 1
|
||||||
return block1([txt1], [b2]);
|
let b2 = block2();
|
||||||
|
ctx[\`abc\`] = b2;
|
||||||
|
let b3 = component(\`Child\`, {val: ctx['abc']}, key + \`__1\`, node, ctx);
|
||||||
|
return block1([], [b3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -183,8 +189,23 @@ exports[`basics t-set with a body expression can be passed in props, and then t-
|
|||||||
exports[`basics t-set with a body expression can be used as textual prop 1`] = `
|
exports[`basics t-set with a body expression can be used as textual prop 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['props'].val;
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`basics t-set with a body expression can be used as textual prop 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -198,25 +219,26 @@ exports[`basics t-set with a body expression can be used as textual prop 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`basics t-set with a body expression can be used as textual prop 2`] = `
|
exports[`basics t-set works 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].val;
|
let d1 = ctx['props'].val;
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`basics t-set works 1`] = `
|
exports[`basics t-set works 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -230,35 +252,11 @@ exports[`basics t-set works 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`basics t-set works 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['props'].val;
|
|
||||||
return block1([txt1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`basics template string in prop 1`] = `
|
exports[`basics template string in prop 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return component(\`Child\`, {propName: \`1\${ctx['someVal']}3\`}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`basics template string in prop 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return text(\`\`);
|
return text(\`\`);
|
||||||
@@ -266,48 +264,14 @@ exports[`basics template string in prop 2`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`bound functions is referentially equal after update 1`] = `
|
exports[`basics template string in prop 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { bind } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`Child\`, {val: ctx['state'].val,fn: bind(ctx, ctx['someFunction'])}, key + \`__1\`, node, ctx);
|
return component(\`Child\`, {propName: \`1\${ctx['someVal']}3\`}, key + \`__1\`, node, ctx);
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`bound functions is referentially equal after update 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return text(ctx['props'].val);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`can bind function prop with bind suffix 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { bind } = helpers;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return component(\`Child\`, {doSomething: bind(ctx, ctx['doSomething'])}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`can bind function prop with bind suffix 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return text(\`child\`);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -3,13 +3,14 @@
|
|||||||
exports[`reactivity in lifecycle can use a state hook 1`] = `
|
exports[`reactivity in lifecycle can use a state hook 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['counter'].value;
|
let d1 = ctx['counter'].value;
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -17,13 +18,14 @@ exports[`reactivity in lifecycle can use a state hook 1`] = `
|
|||||||
exports[`reactivity in lifecycle can use a state hook 2 1`] = `
|
exports[`reactivity in lifecycle can use a state hook 2 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['state'].a;
|
let d1 = ctx['state'].a;
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -31,13 +33,14 @@ exports[`reactivity in lifecycle can use a state hook 2 1`] = `
|
|||||||
exports[`reactivity in lifecycle change state while mounting component 1`] = `
|
exports[`reactivity in lifecycle change state while mounting component 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['state'].val;
|
let d1 = ctx['state'].val;
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -45,7 +48,24 @@ exports[`reactivity in lifecycle change state while mounting component 1`] = `
|
|||||||
exports[`reactivity in lifecycle state changes in willUnmount do not trigger rerender 1`] = `
|
exports[`reactivity in lifecycle state changes in willUnmount do not trigger rerender 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span><block-text-0/><block-text-1/></span>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['props'].val;
|
||||||
|
let d2 = ctx['state'].n;
|
||||||
|
return block1([d1, d2]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`reactivity in lifecycle state changes in willUnmount do not trigger rerender 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -58,18 +78,3 @@ exports[`reactivity in lifecycle state changes in willUnmount do not trigger rer
|
|||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`reactivity in lifecycle state changes in willUnmount do not trigger rerender 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/><block-text-1/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['props'].val;
|
|
||||||
let txt2 = ctx['state'].n;
|
|
||||||
return block1([txt1, txt2]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -3,37 +3,15 @@
|
|||||||
exports[`refs basic use 1`] = `
|
exports[`refs basic use 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-ref=\\"0\\"/>\`);
|
let block1 = createBlock(\`<div block-ref=\\"0\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const refs = ctx.__owl__.refs;
|
const refs = ctx.__owl__.refs;
|
||||||
const ref1 = (el) => refs[\`div\`] = el;
|
let d1 = (el) => refs[\`div\`] = el;
|
||||||
return block1([ref1]);
|
return block1([d1]);
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`refs can use 2 refs with same name in a t-if/t-else situation 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { multiRefSetter } = helpers;
|
|
||||||
|
|
||||||
let block2 = createBlock(\`<div block-ref=\\"0\\"/>\`);
|
|
||||||
let block3 = createBlock(\`<span block-ref=\\"0\\"/>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
const refs = ctx.__owl__.refs;
|
|
||||||
const ref1 = multiRefSetter(refs, \`coucou\`);
|
|
||||||
let b2,b3;
|
|
||||||
if (ctx['state'].value) {
|
|
||||||
b2 = block2([ref1]);
|
|
||||||
} else {
|
|
||||||
b3 = block3([ref1]);
|
|
||||||
}
|
|
||||||
return multi([b2, b3]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -41,33 +19,8 @@ exports[`refs can use 2 refs with same name in a t-if/t-else situation 1`] = `
|
|||||||
exports[`refs refs are properly bound in slots 1`] = `
|
exports[`refs refs are properly bound in slots 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { capture } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><span class=\\"counter\\"><block-text-0/></span><block-child-0/></div>\`);
|
|
||||||
let block2 = createBlock(\`<button block-handler-0=\\"click\\" block-ref=\\"1\\">do something</button>\`);
|
|
||||||
|
|
||||||
function slot1(ctx, node, key = \\"\\") {
|
|
||||||
const refs = ctx.__owl__.refs;
|
|
||||||
const ref1 = (el) => refs[\`myButton\`] = el;
|
|
||||||
let hdlr1 = [ctx['doSomething'], ctx];
|
|
||||||
return block2([hdlr1, ref1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['state'].val;
|
|
||||||
const ctx1 = capture(ctx);
|
|
||||||
let b3 = component(\`Dialog\`, {slots: {'footer': {__render: slot1, __ctx: ctx1}}}, key + \`__1\`, node, ctx);
|
|
||||||
return block1([txt1], [b3]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`refs refs are properly bound in slots 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { callSlot } = helpers;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
|
|
||||||
@@ -78,21 +31,28 @@ exports[`refs refs are properly bound in slots 2`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`refs throws if there are 2 same refs at the same time 1`] = `
|
exports[`refs refs are properly bound in slots 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { multiRefSetter } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block2 = createBlock(\`<div block-ref=\\"0\\"/>\`);
|
let block1 = createBlock(\`<div><span class=\\"counter\\"><block-text-0/></span><block-child-0/></div>\`);
|
||||||
let block3 = createBlock(\`<span block-ref=\\"0\\"/>\`);
|
let block2 = createBlock(\`<button block-handler-0=\\"click\\" block-ref=\\"1\\">do something</button>\`);
|
||||||
|
|
||||||
|
function slot2(ctx, node, key) {
|
||||||
|
const refs = ctx.__owl__.refs
|
||||||
|
let d2 = [ctx['doSomething'], ctx];
|
||||||
|
let d3 = (el) => refs[\`myButton\`] = el;
|
||||||
|
return block2([d2, d3]);
|
||||||
|
}
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const refs = ctx.__owl__.refs;
|
const refs = ctx.__owl__.refs;
|
||||||
const ref1 = multiRefSetter(refs, \`coucou\`);
|
let d1 = ctx['state'].val;
|
||||||
let b2 = block2([ref1]);
|
const ctx1 = capture(ctx);
|
||||||
let b3 = block3([ref1]);
|
let b3 = component(\`Dialog\`, {slots: {'footer': {__render: slot2, __ctx: ctx1}}}, key + \`__3\`, node, ctx);
|
||||||
return multi([b2, b3]);
|
return block1([d1], [b3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -3,10 +3,17 @@
|
|||||||
exports[`style and class handling can set class on multi root component 1`] = `
|
exports[`style and class handling can set class on multi root component 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block2 = createBlock(\`<div>a</div>\`);
|
||||||
|
let block3 = createBlock(\`<span block-attribute-0=\\"class\\">b</span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`Child\`, {class: 'fromparent'}, key + \`__1\`, node, ctx);
|
let b2 = block2();
|
||||||
|
let d1 = ctx['props'].class;
|
||||||
|
let b3 = block3([d1]);
|
||||||
|
return multi([b2, b3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -14,49 +21,8 @@ exports[`style and class handling can set class on multi root component 1`] = `
|
|||||||
exports[`style and class handling can set class on multi root component 2`] = `
|
exports[`style and class handling can set class on multi root component 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block2 = createBlock(\`<div>a</div>\`);
|
|
||||||
let block3 = createBlock(\`<span block-attribute-0=\\"class\\">b</span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let b2 = block2();
|
|
||||||
let attr1 = ctx['props'].class;
|
|
||||||
let b3 = block3([attr1]);
|
|
||||||
return multi([b2, b3]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`style and class handling can set class on sub component, as prop 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return component(\`Child\`, {class: 'some-class'}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`style and class handling can set class on sub component, as prop 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\">child</div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let attr1 = ctx['props'].class;
|
|
||||||
return block1([attr1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`style and class handling can set class on sub sub component 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`Child\`, {class: 'fromparent'}, key + \`__1\`, node, ctx);
|
return component(\`Child\`, {class: 'fromparent'}, key + \`__1\`, node, ctx);
|
||||||
@@ -64,10 +30,53 @@ exports[`style and class handling can set class on sub sub component 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`style and class handling can set class on sub component, as prop 1`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\">child</div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['props'].class;
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`style and class handling can set class on sub component, as prop 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return component(\`Child\`, {class: 'some-class'}, key + \`__1\`, node, ctx);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`style and class handling can set class on sub sub component 1`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\">childchild</div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['props'].class;
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`style and class handling can set class on sub sub component 2`] = `
|
exports[`style and class handling can set class on sub sub component 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`ChildChild\`, {class: (ctx['props'].class||'')+' fromchild'}, key + \`__1\`, node, ctx);
|
return component(\`ChildChild\`, {class: (ctx['props'].class||'')+' fromchild'}, key + \`__1\`, node, ctx);
|
||||||
@@ -78,13 +87,11 @@ exports[`style and class handling can set class on sub sub component 2`] = `
|
|||||||
exports[`style and class handling can set class on sub sub component 3`] = `
|
exports[`style and class handling can set class on sub sub component 3`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\">childchild</div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['props'].class;
|
return component(\`Child\`, {class: 'fromparent'}, key + \`__1\`, node, ctx);
|
||||||
return block1([attr1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -92,10 +99,14 @@ exports[`style and class handling can set class on sub sub component 3`] = `
|
|||||||
exports[`style and class handling can set more than one class on sub component 1`] = `
|
exports[`style and class handling can set more than one class on sub component 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\">child</div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`Child\`, {class: 'a b'}, key + \`__1\`, node, ctx);
|
let d1 = ctx['props'].class;
|
||||||
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -103,13 +114,11 @@ exports[`style and class handling can set more than one class on sub component 1
|
|||||||
exports[`style and class handling can set more than one class on sub component 2`] = `
|
exports[`style and class handling can set more than one class on sub component 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\">child</div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['props'].class;
|
return component(\`Child\`, {class: 'a b'}, key + \`__1\`, node, ctx);
|
||||||
return block1([attr1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -117,7 +126,8 @@ exports[`style and class handling can set more than one class on sub component 2
|
|||||||
exports[`style and class handling can set style and class inside component 1`] = `
|
exports[`style and class handling can set style and class inside component 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div style=\\"font-weight:bold;\\" class=\\"some-class\\">world</div>\`);
|
let block1 = createBlock(\`<div style=\\"font-weight:bold;\\" class=\\"some-class\\">world</div>\`);
|
||||||
|
|
||||||
@@ -130,13 +140,14 @@ exports[`style and class handling can set style and class inside component 1`] =
|
|||||||
exports[`style and class handling class on components do not interfere with user defined classes 1`] = `
|
exports[`style and class handling class on components do not interfere with user defined classes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = {c:ctx['state'].c};
|
let d1 = {c:ctx['state'].c};
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -144,10 +155,14 @@ exports[`style and class handling class on components do not interfere with user
|
|||||||
exports[`style and class handling class on sub component, which is switched to another 1`] = `
|
exports[`style and class handling class on sub component, which is switched to another 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\">a</div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`Child\`, {class: 'someclass',child: ctx['state'].child}, key + \`__1\`, node, ctx);
|
let d1 = ctx['props'].class;
|
||||||
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -155,7 +170,23 @@ exports[`style and class handling class on sub component, which is switched to a
|
|||||||
exports[`style and class handling class on sub component, which is switched to another 2`] = `
|
exports[`style and class handling class on sub component, which is switched to another 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span block-attribute-0=\\"class\\">b</span>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['props'].class;
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`style and class handling class on sub component, which is switched to another 3`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2,b3;
|
let b2,b3;
|
||||||
@@ -169,30 +200,14 @@ exports[`style and class handling class on sub component, which is switched to a
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`style and class handling class on sub component, which is switched to another 3`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\">a</div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let attr1 = ctx['props'].class;
|
|
||||||
return block1([attr1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`style and class handling class on sub component, which is switched to another 4`] = `
|
exports[`style and class handling class on sub component, which is switched to another 4`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<span block-attribute-0=\\"class\\">b</span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['props'].class;
|
return component(\`Child\`, {class: 'someclass',child: ctx['state'].child}, key + \`__1\`, node, ctx);
|
||||||
return block1([attr1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -200,7 +215,23 @@ exports[`style and class handling class on sub component, which is switched to a
|
|||||||
exports[`style and class handling class with extra whitespaces (variation) 1`] = `
|
exports[`style and class handling class with extra whitespaces (variation) 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['props'].class;
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`style and class handling class with extra whitespaces (variation) 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<p><block-child-0/></p>\`);
|
let block1 = createBlock(\`<p><block-child-0/></p>\`);
|
||||||
|
|
||||||
@@ -211,27 +242,17 @@ exports[`style and class handling class with extra whitespaces (variation) 1`] =
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`style and class handling class with extra whitespaces (variation) 2`] = `
|
exports[`style and class handling class with extra whitespaces 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['props'].class;
|
let d1 = ctx['props'].class;
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`style and class handling class with extra whitespaces 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return component(\`Child\`, {class: 'a b c d'}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -239,13 +260,11 @@ exports[`style and class handling class with extra whitespaces 1`] = `
|
|||||||
exports[`style and class handling class with extra whitespaces 2`] = `
|
exports[`style and class handling class with extra whitespaces 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"/>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['props'].class;
|
return component(\`Child\`, {class: 'a b c d'}, key + \`__1\`, node, ctx);
|
||||||
return block1([attr1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -253,10 +272,14 @@ exports[`style and class handling class with extra whitespaces 2`] = `
|
|||||||
exports[`style and class handling component class and parent class combine together 1`] = `
|
exports[`style and class handling component class and parent class combine together 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div class=\\"child\\" block-attribute-0=\\"class\\">child</div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`Child\`, {class: 'from parent'}, key + \`__1\`, node, ctx);
|
let d1 = ctx['props'].class;
|
||||||
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -264,13 +287,11 @@ exports[`style and class handling component class and parent class combine toget
|
|||||||
exports[`style and class handling component class and parent class combine together 2`] = `
|
exports[`style and class handling component class and parent class combine together 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<div class=\\"child\\" block-attribute-0=\\"class\\">child</div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['props'].class;
|
return component(\`Child\`, {class: 'from parent'}, key + \`__1\`, node, ctx);
|
||||||
return block1([attr1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -305,7 +326,23 @@ exports[`style and class handling dynamic t-att-style is properly added and upda
|
|||||||
exports[`style and class handling empty class attribute is not added on widget root el 1`] = `
|
exports[`style and class handling empty class attribute is not added on widget root el 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['props'].class;
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`style and class handling empty class attribute is not added on widget root el 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -316,27 +353,18 @@ exports[`style and class handling empty class attribute is not added on widget r
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`style and class handling empty class attribute is not added on widget root el 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<span block-attribute-0=\\"class\\"/>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let attr1 = ctx['props'].class;
|
|
||||||
return block1([attr1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`style and class handling error in subcomponent with class 1`] = `
|
exports[`style and class handling error in subcomponent with class 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"><block-text-1/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`Child\`, {class: 'a'}, key + \`__1\`, node, ctx);
|
let d1 = ctx['props'].class;
|
||||||
|
let d2 = this.will.crash;
|
||||||
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -344,14 +372,11 @@ exports[`style and class handling error in subcomponent with class 1`] = `
|
|||||||
exports[`style and class handling error in subcomponent with class 2`] = `
|
exports[`style and class handling error in subcomponent with class 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\"><block-text-1/></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['props'].class;
|
return component(\`Child\`, {class: 'a'}, key + \`__1\`, node, ctx);
|
||||||
let txt1 = this.will.crash;
|
|
||||||
return block1([attr1, txt1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -359,18 +384,8 @@ exports[`style and class handling error in subcomponent with class 2`] = `
|
|||||||
exports[`style and class handling no class is set is child ignores it 1`] = `
|
exports[`style and class handling no class is set is child ignores it 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return component(\`Child\`, {class: 'hey'}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`style and class handling no class is set is child ignores it 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>child</div>\`);
|
let block1 = createBlock(\`<div>child</div>\`);
|
||||||
|
|
||||||
@@ -380,13 +395,29 @@ exports[`style and class handling no class is set is child ignores it 2`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`style and class handling no class is set is child ignores it 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return component(\`Child\`, {class: 'hey'}, key + \`__1\`, node, ctx);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`style and class handling no class is set is parent does not give it as prop 1`] = `
|
exports[`style and class handling no class is set is parent does not give it as prop 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div block-attribute-0=\\"class\\">child</div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
let d1 = ctx['props'].class;
|
||||||
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -394,13 +425,11 @@ exports[`style and class handling no class is set is parent does not give it as
|
|||||||
exports[`style and class handling no class is set is parent does not give it as prop 2`] = `
|
exports[`style and class handling no class is set is parent does not give it as prop 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"class\\">child</div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['props'].class;
|
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
||||||
return block1([attr1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -408,10 +437,14 @@ exports[`style and class handling no class is set is parent does not give it as
|
|||||||
exports[`style and class handling style is properly added on widget root el 1`] = `
|
exports[`style and class handling style is properly added on widget root el 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div block-attribute-0=\\"style\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`Child\`, {style: 'font-weight: bold;'}, key + \`__1\`, node, ctx);
|
let d1 = ctx['props'].style;
|
||||||
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -419,13 +452,11 @@ exports[`style and class handling style is properly added on widget root el 1`]
|
|||||||
exports[`style and class handling style is properly added on widget root el 2`] = `
|
exports[`style and class handling style is properly added on widget root el 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"style\\"/>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = ctx['props'].style;
|
return component(\`Child\`, {style: 'font-weight: bold;'}, key + \`__1\`, node, ctx);
|
||||||
return block1([attr1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -433,7 +464,23 @@ exports[`style and class handling style is properly added on widget root el 2`]
|
|||||||
exports[`style and class handling t-att-class is properly added/removed on widget root el (v2) 1`] = `
|
exports[`style and class handling t-att-class is properly added/removed on widget root el (v2) 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span class=\\"c\\" block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = {d:ctx['state'].d,...ctx['props'].class};
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`style and class handling t-att-class is properly added/removed on widget root el (v2) 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -444,27 +491,17 @@ exports[`style and class handling t-att-class is properly added/removed on widge
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`style and class handling t-att-class is properly added/removed on widget root el (v2) 2`] = `
|
exports[`style and class handling t-att-class is properly added/removed on widget root el (v3) 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span class=\\"c\\" block-attribute-0=\\"class\\"/>\`);
|
let block1 = createBlock(\`<span class=\\"c\\" block-attribute-0=\\"class\\"/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = {d:ctx['state'].d,...ctx['props'].class};
|
let d1 = {d:ctx['state'].d,...ctx['props'].class};
|
||||||
return block1([attr1]);
|
return block1([d1]);
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`style and class handling t-att-class is properly added/removed on widget root el (v3) 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return component(\`Child\`, {class: {a:true,b:ctx['state'].b}}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -472,13 +509,11 @@ exports[`style and class handling t-att-class is properly added/removed on widge
|
|||||||
exports[`style and class handling t-att-class is properly added/removed on widget root el (v3) 2`] = `
|
exports[`style and class handling t-att-class is properly added/removed on widget root el (v3) 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<span class=\\"c\\" block-attribute-0=\\"class\\"/>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let attr1 = {d:ctx['state'].d,...ctx['props'].class};
|
return component(\`Child\`, {class: {a:true,b:ctx['state'].b}}, key + \`__1\`, node, ctx);
|
||||||
return block1([attr1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -3,16 +3,16 @@
|
|||||||
exports[`t-call dynamic t-call 1`] = `
|
exports[`t-call dynamic t-call 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, zero, call } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1;
|
ctx[isBoundary] = 1;
|
||||||
let b1 = text(\` owl \`);
|
let b1 = text(\` owl \`);
|
||||||
ctx[zero] = b1;
|
ctx[zero] = b1;
|
||||||
const template1 = (ctx['current'].template);
|
const template2 = (ctx['current'].template);
|
||||||
return call(this, template1, ctx, node, key + \`__1\`);
|
return call(template2, ctx, node, key + \`__1\`);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -20,7 +20,8 @@ exports[`t-call dynamic t-call 1`] = `
|
|||||||
exports[`t-call dynamic t-call 2`] = `
|
exports[`t-call dynamic t-call 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>foo</div>\`);
|
let block1 = createBlock(\`<div>foo</div>\`);
|
||||||
|
|
||||||
@@ -33,7 +34,8 @@ exports[`t-call dynamic t-call 2`] = `
|
|||||||
exports[`t-call dynamic t-call 3`] = `
|
exports[`t-call dynamic t-call 3`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return text(\`bar\`);
|
return text(\`bar\`);
|
||||||
@@ -41,90 +43,17 @@ exports[`t-call dynamic t-call 3`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-call dynamic t-call: key is propagated 1`] = `
|
exports[`t-call handlers are properly bound through a t-call 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { call } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let b2 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
|
||||||
const template1 = (ctx['sub']);
|
|
||||||
let b3 = call(this, template1, ctx, node, key + \`__2\`);
|
|
||||||
return multi([b2, b3]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-call dynamic t-call: key is propagated 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-attribute-0=\\"id\\"/>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let attr1 = ctx['id'];
|
|
||||||
return block1([attr1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-call dynamic t-call: key is propagated 3`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-call handlers are properly bound through a dynamic t-call 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { call } = helpers;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
const template1 = ('__template__999');
|
|
||||||
let b2 = call(this, template1, ctx, node, key + \`__1\`);
|
|
||||||
let txt1 = ctx['counter'];
|
|
||||||
return block1([txt1], [b2]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-call handlers are properly bound through a dynamic t-call 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<p block-handler-0=\\"click\\">lucas</p>\`);
|
let block1 = createBlock(\`<p block-handler-0=\\"click\\">lucas</p>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [()=>this.update(), ctx];
|
let d1 = [ctx['update'], ctx];
|
||||||
return block1([hdlr1]);
|
return block1([d1]);
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-call handlers are properly bound through a t-call 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { getTemplate } = helpers;
|
|
||||||
const callTemplate_1 = getTemplate(\`__template__999\`);
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
|
||||||
let txt1 = ctx['counter'];
|
|
||||||
return block1([txt1], [b2]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -132,13 +61,16 @@ exports[`t-call handlers are properly bound through a t-call 1`] = `
|
|||||||
exports[`t-call handlers are properly bound through a t-call 2`] = `
|
exports[`t-call handlers are properly bound through a t-call 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
const callTemplate_2 = getTemplate(\`__template__9\`);
|
||||||
|
|
||||||
let block1 = createBlock(\`<p block-handler-0=\\"click\\">lucas</p>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [ctx['update'], ctx];
|
let b2 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||||
return block1([hdlr1]);
|
let d1 = ctx['counter'];
|
||||||
|
return block1([d1], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -146,15 +78,15 @@ exports[`t-call handlers are properly bound through a t-call 2`] = `
|
|||||||
exports[`t-call handlers with arguments are properly bound through a t-call 1`] = `
|
exports[`t-call handlers with arguments are properly bound through a t-call 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { getTemplate } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`__template__999\`);
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<p block-handler-0=\\"click\\">lucas</p>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
const v1 = ctx['a'];
|
||||||
return block1([], [b2]);
|
let d1 = [()=>this.update(v1), ctx];
|
||||||
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -162,14 +94,15 @@ exports[`t-call handlers with arguments are properly bound through a t-call 1`]
|
|||||||
exports[`t-call handlers with arguments are properly bound through a t-call 2`] = `
|
exports[`t-call handlers with arguments are properly bound through a t-call 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
const callTemplate_2 = getTemplate(\`__template__9\`);
|
||||||
|
|
||||||
let block1 = createBlock(\`<p block-handler-0=\\"click\\">lucas</p>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const v1 = ctx['a'];
|
let b2 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||||
let hdlr1 = [()=>this.update(v1), ctx];
|
return block1([], [b2]);
|
||||||
return block1([hdlr1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -177,15 +110,11 @@ exports[`t-call handlers with arguments are properly bound through a t-call 2`]
|
|||||||
exports[`t-call parent is set within t-call 1`] = `
|
exports[`t-call parent is set within t-call 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { getTemplate } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`__template__999\`);
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
||||||
return block1([], [b2]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -193,10 +122,13 @@ exports[`t-call parent is set within t-call 1`] = `
|
|||||||
exports[`t-call parent is set within t-call 2`] = `
|
exports[`t-call parent is set within t-call 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span>lucas</span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
return block1();
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -204,12 +136,15 @@ exports[`t-call parent is set within t-call 2`] = `
|
|||||||
exports[`t-call parent is set within t-call 3`] = `
|
exports[`t-call parent is set within t-call 3`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
const callTemplate_2 = getTemplate(\`__template__9\`);
|
||||||
|
|
||||||
let block1 = createBlock(\`<span>lucas</span>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return block1();
|
let b2 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||||
|
return block1([], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -217,20 +152,8 @@ exports[`t-call parent is set within t-call 3`] = `
|
|||||||
exports[`t-call parent is set within t-call with no parentNode 1`] = `
|
exports[`t-call parent is set within t-call with no parentNode 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { getTemplate } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`__template__999\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-call parent is set within t-call with no parentNode 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
||||||
@@ -238,10 +161,11 @@ exports[`t-call parent is set within t-call with no parentNode 2`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-call parent is set within t-call with no parentNode 3`] = `
|
exports[`t-call parent is set within t-call with no parentNode 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span>lucas</span>\`);
|
let block1 = createBlock(\`<span>lucas</span>\`);
|
||||||
|
|
||||||
@@ -251,25 +175,30 @@ exports[`t-call parent is set within t-call with no parentNode 3`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`t-call parent is set within t-call with no parentNode 3`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
const callTemplate_2 = getTemplate(\`__template__9\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`t-call sub components in two t-calls 1`] = `
|
exports[`t-call sub components in two t-calls 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { getTemplate } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`sub\`);
|
|
||||||
const callTemplate_2 = getTemplate(\`sub\`);
|
|
||||||
|
|
||||||
let block3 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2,b3;
|
let d1 = ctx['props'].val;
|
||||||
if (ctx['state'].val===1) {
|
return block1([d1]);
|
||||||
b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
|
||||||
} else {
|
|
||||||
let b4 = callTemplate_2.call(this, ctx, node, key + \`__2\`);
|
|
||||||
b3 = block3([], [b4]);
|
|
||||||
}
|
|
||||||
return multi([b2, b3]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -277,10 +206,22 @@ exports[`t-call sub components in two t-calls 1`] = `
|
|||||||
exports[`t-call sub components in two t-calls 2`] = `
|
exports[`t-call sub components in two t-calls 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
const callTemplate_2 = getTemplate(\`sub\`);
|
||||||
|
const callTemplate_4 = getTemplate(\`sub\`);
|
||||||
|
|
||||||
|
let block3 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return component(\`Child\`, {val: ctx['state'].val}, key + \`__1\`, node, ctx);
|
let b2,b3;
|
||||||
|
if (ctx['state'].val===1) {
|
||||||
|
b2 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||||
|
} else {
|
||||||
|
let b4 = callTemplate_4.call(this, ctx, node, key + \`__3\`);
|
||||||
|
b3 = block3([], [b4]);
|
||||||
|
}
|
||||||
|
return multi([b2, b3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -288,13 +229,11 @@ exports[`t-call sub components in two t-calls 2`] = `
|
|||||||
exports[`t-call sub components in two t-calls 3`] = `
|
exports[`t-call sub components in two t-calls 3`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].val;
|
return component(\`Child\`, {val: ctx['state'].val}, key + \`__1\`, node, ctx);
|
||||||
return block1([txt1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -302,9 +241,36 @@ exports[`t-call sub components in two t-calls 3`] = `
|
|||||||
exports[`t-call t-call in t-foreach and children component 1`] = `
|
exports[`t-call t-call in t-foreach and children component 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, getTemplate, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`__template__999\`);
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return component(\`Child\`, {val: ctx['val']}, key + \`__1\`, node, ctx);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`t-call t-call in t-foreach and children component 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['props'].val;
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`t-call t-call in t-foreach and children component 3`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
const callTemplate_2 = getTemplate(\`__template__9\`);
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -318,35 +284,10 @@ exports[`t-call t-call in t-foreach and children component 1`] = `
|
|||||||
ctx[\`val_index\`] = i1;
|
ctx[\`val_index\`] = i1;
|
||||||
ctx[\`val_value\`] = k_block2[i1];
|
ctx[\`val_value\`] = k_block2[i1];
|
||||||
let key1 = ctx['val'];
|
let key1 = ctx['val'];
|
||||||
c_block2[i1] = withKey(callTemplate_1.call(this, ctx, node, key + \`__1__\${key1}\`), key1);
|
c_block2[i1] = withKey(callTemplate_2.call(this, ctx, node, key + \`__1__\${key1}\`), key1);
|
||||||
}
|
}
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-call t-call in t-foreach and children component 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return component(\`Child\`, {val: ctx['val']}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-call t-call in t-foreach and children component 3`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['props'].val;
|
|
||||||
return block1([txt1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
exports[`t-call-block simple t-call-block with static text 1`] = `
|
exports[`t-call-block simple t-call-block with static text 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
|
|||||||
@@ -3,14 +3,13 @@
|
|||||||
exports[`t-component can switch between dynamic components without the need for a t-key 1`] = `
|
exports[`t-component can switch between dynamic components without the need for a t-key 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<span>child a</span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let Comp1 = ctx['constructor'].components[ctx['state'].child];
|
return block1();
|
||||||
let b2 = toggler(Comp1, component(Comp1, {}, key + \`__1\`, node, ctx));
|
|
||||||
return block1([], [b2]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -18,9 +17,10 @@ exports[`t-component can switch between dynamic components without the need for
|
|||||||
exports[`t-component can switch between dynamic components without the need for a t-key 2`] = `
|
exports[`t-component can switch between dynamic components without the need for a t-key 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span>child a</span>\`);
|
let block1 = createBlock(\`<span>child b</span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return block1();
|
return block1();
|
||||||
@@ -31,12 +31,15 @@ exports[`t-component can switch between dynamic components without the need for
|
|||||||
exports[`t-component can switch between dynamic components without the need for a t-key 3`] = `
|
exports[`t-component can switch between dynamic components without the need for a t-key 3`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span>child b</span>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return block1();
|
let Comp2 = ctx['constructor'].components[ctx['state'].child];
|
||||||
|
let b2 = toggler(Comp2, component(Comp2, {}, key + \`__1\`, node, ctx));
|
||||||
|
return block1([], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -44,12 +47,13 @@ exports[`t-component can switch between dynamic components without the need for
|
|||||||
exports[`t-component can use dynamic components (the class) if given (with different root tagname) 1`] = `
|
exports[`t-component can use dynamic components (the class) if given (with different root tagname) 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span>child a</span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const tKey_1 = ctx['state'].child;
|
return block1();
|
||||||
let Comp1 = ctx['myComponent'];
|
|
||||||
return toggler(tKey_1, toggler(Comp1, component(Comp1, {}, tKey_1 + key + \`__1\`, node, ctx)));
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -57,9 +61,10 @@ exports[`t-component can use dynamic components (the class) if given (with diffe
|
|||||||
exports[`t-component can use dynamic components (the class) if given (with different root tagname) 2`] = `
|
exports[`t-component can use dynamic components (the class) if given (with different root tagname) 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span>child a</span>\`);
|
let block1 = createBlock(\`<div>child b</div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return block1();
|
return block1();
|
||||||
@@ -70,12 +75,13 @@ exports[`t-component can use dynamic components (the class) if given (with diffe
|
|||||||
exports[`t-component can use dynamic components (the class) if given (with different root tagname) 3`] = `
|
exports[`t-component can use dynamic components (the class) if given (with different root tagname) 3`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<div>child b</div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return block1();
|
const tKey_1 = ctx['state'].child;
|
||||||
|
let Comp3 = ctx['myComponent'];
|
||||||
|
return toggler(tKey_1, toggler(Comp3, component(Comp3, {}, tKey_1 + key + \`__2\`, node, ctx)));
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -83,12 +89,13 @@ exports[`t-component can use dynamic components (the class) if given (with diffe
|
|||||||
exports[`t-component can use dynamic components (the class) if given 1`] = `
|
exports[`t-component can use dynamic components (the class) if given 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span>child a</span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const tKey_1 = ctx['state'].child;
|
return block1();
|
||||||
let Comp1 = ctx['myComponent'];
|
|
||||||
return toggler(tKey_1, toggler(Comp1, component(Comp1, {}, tKey_1 + key + \`__1\`, node, ctx)));
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -96,9 +103,10 @@ exports[`t-component can use dynamic components (the class) if given 1`] = `
|
|||||||
exports[`t-component can use dynamic components (the class) if given 2`] = `
|
exports[`t-component can use dynamic components (the class) if given 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span>child a</span>\`);
|
let block1 = createBlock(\`<span>child b</span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return block1();
|
return block1();
|
||||||
@@ -109,12 +117,13 @@ exports[`t-component can use dynamic components (the class) if given 2`] = `
|
|||||||
exports[`t-component can use dynamic components (the class) if given 3`] = `
|
exports[`t-component can use dynamic components (the class) if given 3`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
let block1 = createBlock(\`<span>child b</span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return block1();
|
const tKey_1 = ctx['state'].child;
|
||||||
|
let Comp3 = ctx['myComponent'];
|
||||||
|
return toggler(tKey_1, toggler(Comp3, component(Comp3, {}, tKey_1 + key + \`__2\`, node, ctx)));
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -122,14 +131,16 @@ exports[`t-component can use dynamic components (the class) if given 3`] = `
|
|||||||
exports[`t-component modifying a sub widget 1`] = `
|
exports[`t-component modifying a sub widget 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/><button block-handler-1=\\"click\\">Inc</button></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let Comp1 = ctx['Counter'];
|
let d1 = ctx['state'].counter;
|
||||||
let b2 = toggler(Comp1, component(Comp1, {}, key + \`__1\`, node, ctx));
|
const v1 = ctx['state'];
|
||||||
return block1([], [b2]);
|
let d2 = [()=>v1.counter++, ctx];
|
||||||
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -137,15 +148,15 @@ exports[`t-component modifying a sub widget 1`] = `
|
|||||||
exports[`t-component modifying a sub widget 2`] = `
|
exports[`t-component modifying a sub widget 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/><button block-handler-1=\\"click\\">Inc</button></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['state'].counter;
|
let Comp2 = ctx['Counter'];
|
||||||
const v1 = ctx['state'];
|
let b2 = toggler(Comp2, component(Comp2, {}, key + \`__1\`, node, ctx));
|
||||||
let hdlr1 = [()=>v1.counter++, ctx];
|
return block1([], [b2]);
|
||||||
return block1([txt1, hdlr1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -153,19 +164,8 @@ exports[`t-component modifying a sub widget 2`] = `
|
|||||||
exports[`t-component switching dynamic component 1`] = `
|
exports[`t-component switching dynamic component 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let Comp1 = ctx['Child'];
|
|
||||||
return toggler(Comp1, component(Comp1, {}, key + \`__1\`, node, ctx));
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-component switching dynamic component 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>child a</div>\`);
|
let block1 = createBlock(\`<div>child a</div>\`);
|
||||||
|
|
||||||
@@ -175,10 +175,11 @@ exports[`t-component switching dynamic component 2`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-component switching dynamic component 3`] = `
|
exports[`t-component switching dynamic component 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return text(\`child b\`);
|
return text(\`child b\`);
|
||||||
@@ -186,22 +187,38 @@ exports[`t-component switching dynamic component 3`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-component t-component works in simple case 1`] = `
|
exports[`t-component switching dynamic component 3`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let Comp1 = ctx['Child'];
|
let Comp2 = ctx['Child'];
|
||||||
return toggler(Comp1, component(Comp1, {}, key + \`__1\`, node, ctx));
|
return toggler(Comp2, component(Comp2, {}, key + \`__1\`, node, ctx));
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-component t-component works in simple case 2`] = `
|
exports[`t-component t-component not on a <t> node 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span>1</span>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return block1();
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`t-component t-component works in simple case 1`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div>child</div>\`);
|
let block1 = createBlock(\`<div>child</div>\`);
|
||||||
|
|
||||||
@@ -210,3 +227,16 @@ exports[`t-component t-component works in simple case 2`] = `
|
|||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`t-component t-component works in simple case 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let Comp2 = ctx['Child'];
|
||||||
|
return toggler(Comp2, component(Comp2, {}, key + \`__1\`, node, ctx));
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|||||||
@@ -3,8 +3,23 @@
|
|||||||
exports[`list of components components in a node in a t-foreach 1`] = `
|
exports[`list of components components in a node in a t-foreach 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['props'].item;
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`list of components components in a node in a t-foreach 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><ul><block-child-0/></ul></div>\`);
|
let block1 = createBlock(\`<div><ul><block-child-0/></ul></div>\`);
|
||||||
let block3 = createBlock(\`<li><block-child-0/></li>\`);
|
let block3 = createBlock(\`<li><block-child-0/></li>\`);
|
||||||
@@ -24,25 +39,11 @@ exports[`list of components components in a node in a t-foreach 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`list of components components in a node in a t-foreach 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['props'].item;
|
|
||||||
return block1([txt1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`list of components crash on duplicate key in dev mode 1`] = `
|
exports[`list of components crash on duplicate key in dev mode 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
@@ -55,7 +56,7 @@ exports[`list of components crash on duplicate key in dev mode 1`] = `
|
|||||||
keys1.add(key1);
|
keys1.add(key1);
|
||||||
const props1 = {}
|
const props1 = {}
|
||||||
helpers.validateProps(\`Child\`, props1, ctx)
|
helpers.validateProps(\`Child\`, props1, ctx)
|
||||||
c_block1[i1] = withKey(component(\`Child\`, props1, key + \`__1__\${key1}\`, node, ctx), key1);
|
c_block1[i1] = withKey(component(\`Child\`, props1, key + \`__2__\${key1}\`, node, ctx), key1);
|
||||||
}
|
}
|
||||||
return list(c_block1);
|
return list(c_block1);
|
||||||
}
|
}
|
||||||
@@ -65,7 +66,8 @@ exports[`list of components crash on duplicate key in dev mode 1`] = `
|
|||||||
exports[`list of components crash on duplicate key in dev mode 2`] = `
|
exports[`list of components crash on duplicate key in dev mode 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return text(\`\`);
|
return text(\`\`);
|
||||||
@@ -73,11 +75,44 @@ exports[`list of components crash on duplicate key in dev mode 2`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`list of components crash on duplicate key in dev mode 3`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
ctx = Object.create(ctx);
|
||||||
|
const [k_block1, v_block1, l_block1, c_block1] = prepareList([1,2]);
|
||||||
|
for (let i1 = 0; i1 < l_block1; i1++) {
|
||||||
|
ctx[\`item\`] = v_block1[i1];
|
||||||
|
let key1 = 'child';
|
||||||
|
c_block1[i1] = withKey(component(\`Child\`, {}, key + \`__1__\${key1}\`, node, ctx), key1);
|
||||||
|
}
|
||||||
|
return list(c_block1);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`list of components list of sub components inside other nodes 1`] = `
|
exports[`list of components list of sub components inside other nodes 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span>asdf</span>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
return block1();
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`list of components list of sub components inside other nodes 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block3 = createBlock(\`<div><block-child-0/></div>\`);
|
let block3 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
@@ -97,24 +132,26 @@ exports[`list of components list of sub components inside other nodes 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`list of components list of sub components inside other nodes 2`] = `
|
exports[`list of components reconciliation alg works for t-foreach in t-foreach 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span>asdf</span>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
return block1();
|
let d1 = ctx['props'].blip;
|
||||||
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`list of components reconciliation alg works for t-foreach in t-foreach 1`] = `
|
exports[`list of components reconciliation alg works for t-foreach in t-foreach 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -142,25 +179,26 @@ exports[`list of components reconciliation alg works for t-foreach in t-foreach
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`list of components reconciliation alg works for t-foreach in t-foreach 2`] = `
|
exports[`list of components reconciliation alg works for t-foreach in t-foreach, 2 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].blip;
|
let d1 = ctx['props'].row+'_'+ctx['props'].col;
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`list of components reconciliation alg works for t-foreach in t-foreach, 2 1`] = `
|
exports[`list of components reconciliation alg works for t-foreach in t-foreach, 2 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block3 = createBlock(\`<p><block-child-0/></p>\`);
|
let block3 = createBlock(\`<p><block-child-0/></p>\`);
|
||||||
@@ -190,25 +228,26 @@ exports[`list of components reconciliation alg works for t-foreach in t-foreach,
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`list of components reconciliation alg works for t-foreach in t-foreach, 2 2`] = `
|
exports[`list of components simple list 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].row+'_'+ctx['props'].col;
|
let d1 = ctx['props'].value;
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`list of components simple list 1`] = `
|
exports[`list of components simple list 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
@@ -223,25 +262,26 @@ exports[`list of components simple list 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`list of components simple list 2`] = `
|
exports[`list of components sub components rendered in a loop 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
let block1 = createBlock(\`<p><block-text-0/></p>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].value;
|
let d1 = ctx['props'].n;
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`list of components sub components rendered in a loop 1`] = `
|
exports[`list of components sub components rendered in a loop 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -259,25 +299,26 @@ exports[`list of components sub components rendered in a loop 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`list of components sub components rendered in a loop 2`] = `
|
exports[`list of components sub components with some state rendered in a loop 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<p><block-text-0/></p>\`);
|
let block1 = createBlock(\`<p><block-text-0/></p>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].n;
|
let d1 = ctx['state'].n;
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`list of components sub components with some state rendered in a loop 1`] = `
|
exports[`list of components sub components with some state rendered in a loop 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -295,25 +336,26 @@ exports[`list of components sub components with some state rendered in a loop 1`
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`list of components sub components with some state rendered in a loop 2`] = `
|
exports[`list of components switch component position 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<p><block-text-0/></p>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['state'].n;
|
let d1 = ctx['props'].key;
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`list of components switch component position 1`] = `
|
exports[`list of components switch component position 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
|
|
||||||
@@ -331,25 +373,27 @@ exports[`list of components switch component position 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`list of components switch component position 2`] = `
|
exports[`list of components t-foreach with t-component, and update 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<span><block-text-0/><block-text-1/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].key;
|
let d1 = ctx['state'].val;
|
||||||
return block1([txt1]);
|
let d2 = ctx['props'].val;
|
||||||
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`list of components t-foreach with t-component, and update 1`] = `
|
exports[`list of components t-foreach with t-component, and update 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -367,18 +411,3 @@ exports[`list of components t-foreach with t-component, and update 1`] = `
|
|||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`list of components t-foreach with t-component, and update 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/><block-text-1/></span>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['state'].val;
|
|
||||||
let txt2 = ctx['props'].val;
|
|
||||||
return block1([txt1, txt2]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -3,8 +3,23 @@
|
|||||||
exports[`t-key t-foreach with t-key switch component position 1`] = `
|
exports[`t-key t-foreach with t-key switch component position 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['props'].key;
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`t-key t-foreach with t-key switch component position 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
|
|
||||||
@@ -15,7 +30,7 @@ exports[`t-key t-foreach with t-key switch component position 1`] = `
|
|||||||
ctx[\`c\`] = v_block2[i1];
|
ctx[\`c\`] = v_block2[i1];
|
||||||
let key1 = ctx['c'];
|
let key1 = ctx['c'];
|
||||||
const tKey_1 = ctx['key1'];
|
const tKey_1 = ctx['key1'];
|
||||||
c_block2[i1] = withKey(component(\`Child\`, {key: ctx['c']+ctx['key1']}, tKey_1 + key + \`__1__\${key1}\`, node, ctx), tKey_1 + key1);
|
c_block2[i1] = withKey(component(\`Child\`, {key: ctx['c']+ctx['key1']}, tKey_1 + key + \`__2__\${key1}\`, node, ctx), tKey_1 + key1);
|
||||||
}
|
}
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
@@ -23,28 +38,17 @@ exports[`t-key t-foreach with t-key switch component position 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-key t-foreach with t-key switch component position 2`] = `
|
exports[`t-key t-key on Component 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].key;
|
let d1 = ctx['props'].key;
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-key t-key on Component 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
const tKey_1 = ctx['key'];
|
|
||||||
return toggler(tKey_1, component(\`Child\`, {key: ctx['key']}, tKey_1 + key + \`__1\`, node, ctx));
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -52,13 +56,15 @@ exports[`t-key t-key on Component 1`] = `
|
|||||||
exports[`t-key t-key on Component 2`] = `
|
exports[`t-key t-key on Component 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].key;
|
const tKey_1 = ctx['key'];
|
||||||
return block1([txt1]);
|
let b2 = toggler(tKey_1, component(\`Child\`, {key: ctx['key']}, tKey_1 + key + \`__2\`, node, ctx));
|
||||||
|
return block1([], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -66,14 +72,14 @@ exports[`t-key t-key on Component 2`] = `
|
|||||||
exports[`t-key t-key on Component as a function 1`] = `
|
exports[`t-key t-key on Component as a function 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const tKey_1 = ctx['key'];
|
let d1 = ctx['props'].key;
|
||||||
let b2 = toggler(tKey_1, component(\`Child\`, {key: ctx['key']}, tKey_1 + key + \`__1\`, node, ctx));
|
return block1([d1]);
|
||||||
return block1([], [b2]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -81,13 +87,15 @@ exports[`t-key t-key on Component as a function 1`] = `
|
|||||||
exports[`t-key t-key on Component as a function 2`] = `
|
exports[`t-key t-key on Component as a function 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].key;
|
const tKey_1 = ctx['key'];
|
||||||
return block1([txt1]);
|
let b2 = toggler(tKey_1, component(\`Child\`, {key: ctx['key']}, tKey_1 + key + \`__2\`, node, ctx));
|
||||||
|
return block1([], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -95,16 +103,14 @@ exports[`t-key t-key on Component as a function 2`] = `
|
|||||||
exports[`t-key t-key on multiple Components 1`] = `
|
exports[`t-key t-key on multiple Components 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/><block-child-1/></span>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const tKey_1 = ctx['key1'];
|
let d1 = ctx['props'].key;
|
||||||
let b2 = toggler(tKey_1, component(\`Child\`, {key: ctx['key1']}, tKey_1 + key + \`__1\`, node, ctx));
|
return block1([d1]);
|
||||||
const tKey_2 = ctx['key2'];
|
|
||||||
let b3 = toggler(tKey_2, component(\`Child\`, {key: ctx['key2']}, tKey_2 + key + \`__2\`, node, ctx));
|
|
||||||
return block1([], [b2, b3]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -112,13 +118,17 @@ exports[`t-key t-key on multiple Components 1`] = `
|
|||||||
exports[`t-key t-key on multiple Components 2`] = `
|
exports[`t-key t-key on multiple Components 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<span><block-child-0/><block-child-1/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].key;
|
const tKey_1 = ctx['key1'];
|
||||||
return block1([txt1]);
|
let b2 = toggler(tKey_1, component(\`Child\`, {key: ctx['key1']}, tKey_1 + key + \`__2\`, node, ctx));
|
||||||
|
const tKey_3 = ctx['key2'];
|
||||||
|
let b3 = toggler(tKey_3, component(\`Child\`, {key: ctx['key2']}, tKey_3 + key + \`__4\`, node, ctx));
|
||||||
|
return block1([], [b2, b3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -126,10 +136,38 @@ exports[`t-key t-key on multiple Components 2`] = `
|
|||||||
exports[`t-key t-key on multiple Components with t-call 1 1`] = `
|
exports[`t-key t-key on multiple Components with t-call 1 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue, getTemplate } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`calledTemplate\`);
|
|
||||||
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['props'].key;
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`t-key t-key on multiple Components with t-call 1 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
const tKey_1 = ctx['key'];
|
||||||
|
return toggler(tKey_1, component(\`Child\`, {key: ctx['key']}, tKey_1 + key + \`__2\`, node, ctx));
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`t-key t-key on multiple Components with t-call 1 3`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_2 = getTemplate(\`calledTemplate\`);
|
const callTemplate_2 = getTemplate(\`calledTemplate\`);
|
||||||
|
const callTemplate_4 = getTemplate(\`calledTemplate\`);
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/><block-child-1/></span>\`);
|
let block1 = createBlock(\`<span><block-child-0/><block-child-1/></span>\`);
|
||||||
|
|
||||||
@@ -139,55 +177,28 @@ exports[`t-key t-key on multiple Components with t-call 1 1`] = `
|
|||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1;
|
ctx[isBoundary] = 1;
|
||||||
setContextValue(ctx, \\"key\\", ctx['key1']);
|
setContextValue(ctx, \\"key\\", ctx['key1']);
|
||||||
let b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
let b2 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||||
ctx = ctx.__proto__;
|
ctx = ctx.__proto__;
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1;
|
ctx[isBoundary] = 1;
|
||||||
setContextValue(ctx, \\"key\\", ctx['key2']);
|
setContextValue(ctx, \\"key\\", ctx['key2']);
|
||||||
let b3 = callTemplate_2.call(this, ctx, node, key + \`__2\`);
|
let b3 = callTemplate_4.call(this, ctx, node, key + \`__3\`);
|
||||||
return block1([], [b2, b3]);
|
return block1([], [b2, b3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-key t-key on multiple Components with t-call 1 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
const tKey_1 = ctx['key'];
|
|
||||||
return toggler(tKey_1, component(\`Child\`, {key: ctx['key']}, tKey_1 + key + \`__1\`, node, ctx));
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-key t-key on multiple Components with t-call 1 3`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let txt1 = ctx['props'].key;
|
|
||||||
return block1([txt1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-key t-key on multiple Components with t-call 2 1`] = `
|
exports[`t-key t-key on multiple Components with t-call 2 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { getTemplate } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
const callTemplate_1 = getTemplate(\`calledTemplate\`);
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2 = callTemplate_1.call(this, ctx, node, key + \`__1\`);
|
let d1 = ctx['props'].key;
|
||||||
return block1([], [b2]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -195,13 +206,14 @@ exports[`t-key t-key on multiple Components with t-call 2 1`] = `
|
|||||||
exports[`t-key t-key on multiple Components with t-call 2 2`] = `
|
exports[`t-key t-key on multiple Components with t-call 2 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const tKey_1 = ctx['key1'];
|
const tKey_1 = ctx['key1'];
|
||||||
let b2 = toggler(tKey_1, component(\`Child\`, {key: ctx['key1']}, tKey_1 + key + \`__1\`, node, ctx));
|
let b2 = toggler(tKey_1, component(\`Child\`, {key: ctx['key1']}, tKey_1 + key + \`__2\`, node, ctx));
|
||||||
const tKey_2 = ctx['key2'];
|
const tKey_3 = ctx['key2'];
|
||||||
let b3 = toggler(tKey_2, component(\`Child\`, {key: ctx['key2']}, tKey_2 + key + \`__2\`, node, ctx));
|
let b3 = toggler(tKey_3, component(\`Child\`, {key: ctx['key2']}, tKey_3 + key + \`__4\`, node, ctx));
|
||||||
return multi([b2, b3]);
|
return multi([b2, b3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
@@ -210,13 +222,15 @@ exports[`t-key t-key on multiple Components with t-call 2 2`] = `
|
|||||||
exports[`t-key t-key on multiple Components with t-call 2 3`] = `
|
exports[`t-key t-key on multiple Components with t-call 2 3`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
const callTemplate_2 = getTemplate(\`calledTemplate\`);
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].key;
|
let b2 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||||
return block1([txt1]);
|
return block1([], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -3,17 +3,17 @@
|
|||||||
exports[`t-model directive .lazy modifier 1`] = `
|
exports[`t-model directive .lazy modifier 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { toNumber } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"change\\"/><span><block-text-2/></span></div>\`);
|
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"change\\"/><span><block-text-2/></span></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const bExpr1 = ctx['state'];
|
const bExpr1 = ctx['state'];
|
||||||
let attr1 = ctx['state']['text'];
|
let d1 = ctx['state']['text'];
|
||||||
let hdlr1 = [(ev) => { bExpr1['text'] = ev.target.value; }];
|
let d2 = [(ev) => { bExpr1['text'] = ev.target.value; }];
|
||||||
let txt1 = ctx['state'].text;
|
let d3 = ctx['state'].text;
|
||||||
return block1([attr1, hdlr1, txt1]);
|
return block1([d1, d2, d3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -21,17 +21,17 @@ exports[`t-model directive .lazy modifier 1`] = `
|
|||||||
exports[`t-model directive .number modifier 1`] = `
|
exports[`t-model directive .number modifier 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { toNumber } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`);
|
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const bExpr1 = ctx['state'];
|
const bExpr1 = ctx['state'];
|
||||||
let attr1 = ctx['state']['number'];
|
let d1 = ctx['state']['number'];
|
||||||
let hdlr1 = [(ev) => { bExpr1['number'] = toNumber(ev.target.value); }];
|
let d2 = [(ev) => { bExpr1['number'] = toNumber(ev.target.value); }];
|
||||||
let txt1 = ctx['state'].number;
|
let d3 = ctx['state'].number;
|
||||||
return block1([attr1, hdlr1, txt1]);
|
return block1([d1, d2, d3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -39,17 +39,17 @@ exports[`t-model directive .number modifier 1`] = `
|
|||||||
exports[`t-model directive .trim modifier 1`] = `
|
exports[`t-model directive .trim modifier 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { toNumber } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`);
|
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const bExpr1 = ctx['state'];
|
const bExpr1 = ctx['state'];
|
||||||
let attr1 = ctx['state']['text'];
|
let d1 = ctx['state']['text'];
|
||||||
let hdlr1 = [(ev) => { bExpr1['text'] = ev.target.value.trim(); }];
|
let d2 = [(ev) => { bExpr1['text'] = ev.target.value.trim(); }];
|
||||||
let txt1 = ctx['state'].text;
|
let d3 = ctx['state'].text;
|
||||||
return block1([attr1, hdlr1, txt1]);
|
return block1([d1, d2, d3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -57,17 +57,17 @@ exports[`t-model directive .trim modifier 1`] = `
|
|||||||
exports[`t-model directive basic use, on an input 1`] = `
|
exports[`t-model directive basic use, on an input 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { toNumber } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`);
|
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const bExpr1 = ctx['state'];
|
const bExpr1 = ctx['state'];
|
||||||
let attr1 = ctx['state']['text'];
|
let d1 = ctx['state']['text'];
|
||||||
let hdlr1 = [(ev) => { bExpr1['text'] = ev.target.value; }];
|
let d2 = [(ev) => { bExpr1['text'] = ev.target.value; }];
|
||||||
let txt1 = ctx['state'].text;
|
let d3 = ctx['state'].text;
|
||||||
return block1([attr1, hdlr1, txt1]);
|
return block1([d1, d2, d3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -75,17 +75,17 @@ exports[`t-model directive basic use, on an input 1`] = `
|
|||||||
exports[`t-model directive basic use, on an input with bracket expression 1`] = `
|
exports[`t-model directive basic use, on an input with bracket expression 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { toNumber } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`);
|
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const bExpr1 = ctx['state'];
|
const bExpr1 = ctx['state'];
|
||||||
let attr1 = ctx['state']['text'];
|
let d1 = ctx['state']['text'];
|
||||||
let hdlr1 = [(ev) => { bExpr1['text'] = ev.target.value; }];
|
let d2 = [(ev) => { bExpr1['text'] = ev.target.value; }];
|
||||||
let txt1 = ctx['state'].text;
|
let d3 = ctx['state'].text;
|
||||||
return block1([attr1, hdlr1, txt1]);
|
return block1([d1, d2, d3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -93,17 +93,17 @@ exports[`t-model directive basic use, on an input with bracket expression 1`] =
|
|||||||
exports[`t-model directive basic use, on another key in component 1`] = `
|
exports[`t-model directive basic use, on another key in component 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { toNumber } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`);
|
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const bExpr1 = ctx['some'];
|
const bExpr1 = ctx['some'];
|
||||||
let attr1 = ctx['some']['text'];
|
let d1 = ctx['some']['text'];
|
||||||
let hdlr1 = [(ev) => { bExpr1['text'] = ev.target.value; }];
|
let d2 = [(ev) => { bExpr1['text'] = ev.target.value; }];
|
||||||
let txt1 = ctx['some'].text;
|
let d3 = ctx['some'].text;
|
||||||
return block1([attr1, hdlr1, txt1]);
|
return block1([d1, d2, d3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -111,17 +111,17 @@ exports[`t-model directive basic use, on another key in component 1`] = `
|
|||||||
exports[`t-model directive can also define t-on directive on same event, part 1 1`] = `
|
exports[`t-model directive can also define t-on directive on same event, part 1 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { toNumber } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><input block-handler-0=\\"input\\" block-attribute-1=\\"value\\" block-handler-2=\\"input\\"/></div>\`);
|
let block1 = createBlock(\`<div><input block-handler-0=\\"input\\" block-attribute-1=\\"value\\" block-handler-2=\\"input\\"/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [ctx['onInput'], ctx];
|
let d1 = [ctx['onInput'], ctx];
|
||||||
const bExpr1 = ctx['state'];
|
const bExpr1 = ctx['state'];
|
||||||
let attr1 = ctx['state']['text'];
|
let d2 = ctx['state']['text'];
|
||||||
let hdlr2 = [(ev) => { bExpr1['text'] = ev.target.value; }];
|
let d3 = [(ev) => { bExpr1['text'] = ev.target.value; }];
|
||||||
return block1([hdlr1, attr1, hdlr2]);
|
return block1([d1, d2, d3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -129,25 +129,25 @@ exports[`t-model directive can also define t-on directive on same event, part 1
|
|||||||
exports[`t-model directive can also define t-on directive on same event, part 2 1`] = `
|
exports[`t-model directive can also define t-on directive on same event, part 2 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { toNumber } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><input type=\\"radio\\" id=\\"one\\" value=\\"One\\" block-handler-0=\\"click\\" block-attribute-1=\\"checked\\" block-handler-2=\\"click\\"/><input type=\\"radio\\" id=\\"two\\" value=\\"Two\\" block-handler-3=\\"click\\" block-attribute-4=\\"checked\\" block-handler-5=\\"click\\"/><input type=\\"radio\\" id=\\"three\\" value=\\"Three\\" block-handler-6=\\"click\\" block-attribute-7=\\"checked\\" block-handler-8=\\"click\\"/></div>\`);
|
let block1 = createBlock(\`<div><input type=\\"radio\\" id=\\"one\\" value=\\"One\\" block-handler-0=\\"click\\" block-attribute-1=\\"checked\\" block-handler-2=\\"click\\"/><input type=\\"radio\\" id=\\"two\\" value=\\"Two\\" block-handler-3=\\"click\\" block-attribute-4=\\"checked\\" block-handler-5=\\"click\\"/><input type=\\"radio\\" id=\\"three\\" value=\\"Three\\" block-handler-6=\\"click\\" block-attribute-7=\\"checked\\" block-handler-8=\\"click\\"/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let hdlr1 = [ctx['onClick'], ctx];
|
let d1 = [ctx['onClick'], ctx];
|
||||||
const bExpr1 = ctx['state'];
|
const bExpr1 = ctx['state'];
|
||||||
let attr1 = ctx['state']['choice'] === 'One';
|
let d2 = ctx['state']['choice'] === 'One';
|
||||||
let hdlr2 = [(ev) => { bExpr1['choice'] = ev.target.value; }];
|
let d3 = [(ev) => { bExpr1['choice'] = ev.target.value; }];
|
||||||
let hdlr3 = [ctx['onClick'], ctx];
|
let d4 = [ctx['onClick'], ctx];
|
||||||
const bExpr2 = ctx['state'];
|
const bExpr2 = ctx['state'];
|
||||||
let attr2 = ctx['state']['choice'] === 'Two';
|
let d5 = ctx['state']['choice'] === 'Two';
|
||||||
let hdlr4 = [(ev) => { bExpr2['choice'] = ev.target.value; }];
|
let d6 = [(ev) => { bExpr2['choice'] = ev.target.value; }];
|
||||||
let hdlr5 = [ctx['onClick'], ctx];
|
let d7 = [ctx['onClick'], ctx];
|
||||||
const bExpr3 = ctx['state'];
|
const bExpr3 = ctx['state'];
|
||||||
let attr3 = ctx['state']['choice'] === 'Three';
|
let d8 = ctx['state']['choice'] === 'Three';
|
||||||
let hdlr6 = [(ev) => { bExpr3['choice'] = ev.target.value; }];
|
let d9 = [(ev) => { bExpr3['choice'] = ev.target.value; }];
|
||||||
return block1([hdlr1, attr1, hdlr2, hdlr3, attr2, hdlr4, hdlr5, attr3, hdlr6]);
|
return block1([d1, d2, d3, d4, d5, d6, d7, d8, d9]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -155,8 +155,8 @@ exports[`t-model directive can also define t-on directive on same event, part 2
|
|||||||
exports[`t-model directive following a scope protecting directive (e.g. t-set) 1`] = `
|
exports[`t-model directive following a scope protecting directive (e.g. t-set) 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue, toNumber } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/></div>\`);
|
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/></div>\`);
|
||||||
|
|
||||||
@@ -165,9 +165,9 @@ exports[`t-model directive following a scope protecting directive (e.g. t-set) 1
|
|||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"admiral\\", 'Bruno');
|
setContextValue(ctx, \\"admiral\\", 'Bruno');
|
||||||
const bExpr1 = ctx['state'];
|
const bExpr1 = ctx['state'];
|
||||||
let attr1 = ctx['state']['text'];
|
let d1 = ctx['state']['text'];
|
||||||
let hdlr1 = [(ev) => { bExpr1['text'] = ev.target.value; }];
|
let d2 = [(ev) => { bExpr1['text'] = ev.target.value; }];
|
||||||
return block1([attr1, hdlr1]);
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -175,8 +175,8 @@ exports[`t-model directive following a scope protecting directive (e.g. t-set) 1
|
|||||||
exports[`t-model directive in a t-foreach 1`] = `
|
exports[`t-model directive in a t-foreach 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, toNumber, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block3 = createBlock(\`<input type=\\"checkbox\\" block-attribute-0=\\"checked\\" block-handler-1=\\"input\\"/>\`);
|
let block3 = createBlock(\`<input type=\\"checkbox\\" block-attribute-0=\\"checked\\" block-handler-1=\\"input\\"/>\`);
|
||||||
@@ -188,9 +188,9 @@ exports[`t-model directive in a t-foreach 1`] = `
|
|||||||
ctx[\`thing\`] = v_block2[i1];
|
ctx[\`thing\`] = v_block2[i1];
|
||||||
let key1 = ctx['thing'].id;
|
let key1 = ctx['thing'].id;
|
||||||
const bExpr1 = ctx['thing'];
|
const bExpr1 = ctx['thing'];
|
||||||
let attr1 = ctx['thing']['f'];
|
let d1 = ctx['thing']['f'];
|
||||||
let hdlr1 = [(ev) => { bExpr1['f'] = ev.target.checked; }];
|
let d2 = [(ev) => { bExpr1['f'] = ev.target.checked; }];
|
||||||
c_block2[i1] = withKey(block3([attr1, hdlr1]), key1);
|
c_block2[i1] = withKey(block3([d1, d2]), key1);
|
||||||
}
|
}
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
@@ -201,8 +201,8 @@ exports[`t-model directive in a t-foreach 1`] = `
|
|||||||
exports[`t-model directive in a t-foreach, part 2 1`] = `
|
exports[`t-model directive in a t-foreach, part 2 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, toNumber, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block3 = createBlock(\`<input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>\`);
|
let block3 = createBlock(\`<input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>\`);
|
||||||
@@ -215,9 +215,9 @@ exports[`t-model directive in a t-foreach, part 2 1`] = `
|
|||||||
ctx[\`thing_index\`] = i1;
|
ctx[\`thing_index\`] = i1;
|
||||||
let key1 = ctx['thing_index'];
|
let key1 = ctx['thing_index'];
|
||||||
const bExpr1 = ctx['state'];
|
const bExpr1 = ctx['state'];
|
||||||
let attr1 = ctx['state'][ctx['thing_index']];
|
let d1 = ctx['state'][ctx['thing_index']];
|
||||||
let hdlr1 = [(ev) => { bExpr1[ctx['thing_index']] = ev.target.value; }];
|
let d2 = [(ev) => { bExpr1[ctx['thing_index']] = ev.target.value; }];
|
||||||
c_block2[i1] = withKey(block3([attr1, hdlr1]), key1);
|
c_block2[i1] = withKey(block3([d1, d2]), key1);
|
||||||
}
|
}
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
@@ -228,17 +228,17 @@ exports[`t-model directive in a t-foreach, part 2 1`] = `
|
|||||||
exports[`t-model directive on a select 1`] = `
|
exports[`t-model directive on a select 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { toNumber } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><select block-attribute-0=\\"value\\" block-handler-1=\\"change\\"><option value=\\"\\">Please select one</option><option value=\\"red\\">Red</option><option value=\\"blue\\">Blue</option></select><span>Choice: <block-text-2/></span></div>\`);
|
let block1 = createBlock(\`<div><select block-attribute-0=\\"value\\" block-handler-1=\\"change\\"><option value=\\"\\">Please select one</option><option value=\\"red\\">Red</option><option value=\\"blue\\">Blue</option></select><span>Choice: <block-text-2/></span></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const bExpr1 = ctx['state'];
|
const bExpr1 = ctx['state'];
|
||||||
let attr1 = ctx['state']['color'];
|
let d1 = ctx['state']['color'];
|
||||||
let hdlr1 = [(ev) => { bExpr1['color'] = ev.target.value; }];
|
let d2 = [(ev) => { bExpr1['color'] = ev.target.value; }];
|
||||||
let txt1 = ctx['state'].color;
|
let d3 = ctx['state'].color;
|
||||||
return block1([attr1, hdlr1, txt1]);
|
return block1([d1, d2, d3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -246,16 +246,16 @@ exports[`t-model directive on a select 1`] = `
|
|||||||
exports[`t-model directive on a select, initial state 1`] = `
|
exports[`t-model directive on a select, initial state 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { toNumber } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><select block-attribute-0=\\"value\\" block-handler-1=\\"change\\"><option value=\\"\\">Please select one</option><option value=\\"red\\">Red</option><option value=\\"blue\\">Blue</option></select></div>\`);
|
let block1 = createBlock(\`<div><select block-attribute-0=\\"value\\" block-handler-1=\\"change\\"><option value=\\"\\">Please select one</option><option value=\\"red\\">Red</option><option value=\\"blue\\">Blue</option></select></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const bExpr1 = ctx['state'];
|
const bExpr1 = ctx['state'];
|
||||||
let attr1 = ctx['state']['color'];
|
let d1 = ctx['state']['color'];
|
||||||
let hdlr1 = [(ev) => { bExpr1['color'] = ev.target.value; }];
|
let d2 = [(ev) => { bExpr1['color'] = ev.target.value; }];
|
||||||
return block1([attr1, hdlr1]);
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -263,17 +263,17 @@ exports[`t-model directive on a select, initial state 1`] = `
|
|||||||
exports[`t-model directive on a sub state key 1`] = `
|
exports[`t-model directive on a sub state key 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { toNumber } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`);
|
let block1 = createBlock(\`<div><input block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const bExpr1 = ctx['state'].something;
|
const bExpr1 = ctx['state'].something;
|
||||||
let attr1 = ctx['state'].something['text'];
|
let d1 = ctx['state'].something['text'];
|
||||||
let hdlr1 = [(ev) => { bExpr1['text'] = ev.target.value; }];
|
let d2 = [(ev) => { bExpr1['text'] = ev.target.value; }];
|
||||||
let txt1 = ctx['state'].something.text;
|
let d3 = ctx['state'].something.text;
|
||||||
return block1([attr1, hdlr1, txt1]);
|
return block1([d1, d2, d3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -281,20 +281,20 @@ exports[`t-model directive on a sub state key 1`] = `
|
|||||||
exports[`t-model directive on an input type=radio 1`] = `
|
exports[`t-model directive on an input type=radio 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { toNumber } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><input type=\\"radio\\" id=\\"one\\" value=\\"One\\" block-attribute-0=\\"checked\\" block-handler-1=\\"click\\"/><input type=\\"radio\\" id=\\"two\\" value=\\"Two\\" block-attribute-2=\\"checked\\" block-handler-3=\\"click\\"/><span>Choice: <block-text-4/></span></div>\`);
|
let block1 = createBlock(\`<div><input type=\\"radio\\" id=\\"one\\" value=\\"One\\" block-attribute-0=\\"checked\\" block-handler-1=\\"click\\"/><input type=\\"radio\\" id=\\"two\\" value=\\"Two\\" block-attribute-2=\\"checked\\" block-handler-3=\\"click\\"/><span>Choice: <block-text-4/></span></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const bExpr1 = ctx['state'];
|
const bExpr1 = ctx['state'];
|
||||||
let attr1 = ctx['state']['choice'] === 'One';
|
let d1 = ctx['state']['choice'] === 'One';
|
||||||
let hdlr1 = [(ev) => { bExpr1['choice'] = ev.target.value; }];
|
let d2 = [(ev) => { bExpr1['choice'] = ev.target.value; }];
|
||||||
const bExpr2 = ctx['state'];
|
const bExpr2 = ctx['state'];
|
||||||
let attr2 = ctx['state']['choice'] === 'Two';
|
let d3 = ctx['state']['choice'] === 'Two';
|
||||||
let hdlr2 = [(ev) => { bExpr2['choice'] = ev.target.value; }];
|
let d4 = [(ev) => { bExpr2['choice'] = ev.target.value; }];
|
||||||
let txt1 = ctx['state'].choice;
|
let d5 = ctx['state'].choice;
|
||||||
return block1([attr1, hdlr1, attr2, hdlr2, txt1]);
|
return block1([d1, d2, d3, d4, d5]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -302,19 +302,19 @@ exports[`t-model directive on an input type=radio 1`] = `
|
|||||||
exports[`t-model directive on an input type=radio, with initial value 1`] = `
|
exports[`t-model directive on an input type=radio, with initial value 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { toNumber } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><input type=\\"radio\\" id=\\"one\\" value=\\"One\\" block-attribute-0=\\"checked\\" block-handler-1=\\"click\\"/><input type=\\"radio\\" id=\\"two\\" value=\\"Two\\" block-attribute-2=\\"checked\\" block-handler-3=\\"click\\"/></div>\`);
|
let block1 = createBlock(\`<div><input type=\\"radio\\" id=\\"one\\" value=\\"One\\" block-attribute-0=\\"checked\\" block-handler-1=\\"click\\"/><input type=\\"radio\\" id=\\"two\\" value=\\"Two\\" block-attribute-2=\\"checked\\" block-handler-3=\\"click\\"/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const bExpr1 = ctx['state'];
|
const bExpr1 = ctx['state'];
|
||||||
let attr1 = ctx['state']['choice'] === 'One';
|
let d1 = ctx['state']['choice'] === 'One';
|
||||||
let hdlr1 = [(ev) => { bExpr1['choice'] = ev.target.value; }];
|
let d2 = [(ev) => { bExpr1['choice'] = ev.target.value; }];
|
||||||
const bExpr2 = ctx['state'];
|
const bExpr2 = ctx['state'];
|
||||||
let attr2 = ctx['state']['choice'] === 'Two';
|
let d3 = ctx['state']['choice'] === 'Two';
|
||||||
let hdlr2 = [(ev) => { bExpr2['choice'] = ev.target.value; }];
|
let d4 = [(ev) => { bExpr2['choice'] = ev.target.value; }];
|
||||||
return block1([attr1, hdlr1, attr2, hdlr2]);
|
return block1([d1, d2, d3, d4]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -322,22 +322,22 @@ exports[`t-model directive on an input type=radio, with initial value 1`] = `
|
|||||||
exports[`t-model directive on an input, type=checkbox 1`] = `
|
exports[`t-model directive on an input, type=checkbox 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { toNumber } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><input type=\\"checkbox\\" block-attribute-0=\\"checked\\" block-handler-1=\\"input\\"/><span><block-child-0/><block-child-1/></span></div>\`);
|
let block1 = createBlock(\`<div><input type=\\"checkbox\\" block-attribute-0=\\"checked\\" block-handler-1=\\"input\\"/><span><block-child-0/><block-child-1/></span></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b2,b3;
|
let b2,b3;
|
||||||
const bExpr1 = ctx['state'];
|
const bExpr1 = ctx['state'];
|
||||||
let attr1 = ctx['state']['flag'];
|
let d1 = ctx['state']['flag'];
|
||||||
let hdlr1 = [(ev) => { bExpr1['flag'] = ev.target.checked; }];
|
let d2 = [(ev) => { bExpr1['flag'] = ev.target.checked; }];
|
||||||
if (ctx['state'].flag) {
|
if (ctx['state'].flag) {
|
||||||
b2 = text(\`yes\`);
|
b2 = text(\`yes\`);
|
||||||
} else {
|
} else {
|
||||||
b3 = text(\`no\`);
|
b3 = text(\`no\`);
|
||||||
}
|
}
|
||||||
return block1([attr1, hdlr1], [b2, b3]);
|
return block1([d1, d2], [b2, b3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -345,17 +345,17 @@ exports[`t-model directive on an input, type=checkbox 1`] = `
|
|||||||
exports[`t-model directive on an textarea 1`] = `
|
exports[`t-model directive on an textarea 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { toNumber } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><textarea block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`);
|
let block1 = createBlock(\`<div><textarea block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/><span><block-text-2/></span></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
const bExpr1 = ctx['state'];
|
const bExpr1 = ctx['state'];
|
||||||
let attr1 = ctx['state']['text'];
|
let d1 = ctx['state']['text'];
|
||||||
let hdlr1 = [(ev) => { bExpr1['text'] = ev.target.value; }];
|
let d2 = [(ev) => { bExpr1['text'] = ev.target.value; }];
|
||||||
let txt1 = ctx['state'].text;
|
let d3 = ctx['state'].text;
|
||||||
return block1([attr1, hdlr1, txt1]);
|
return block1([d1, d2, d3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -363,8 +363,8 @@ exports[`t-model directive on an textarea 1`] = `
|
|||||||
exports[`t-model directive two inputs in a div alternating with a t-if 1`] = `
|
exports[`t-model directive two inputs in a div alternating with a t-if 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { toNumber } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
|
||||||
let block2 = createBlock(\`<input class=\\"a\\" block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>\`);
|
let block2 = createBlock(\`<input class=\\"a\\" block-attribute-0=\\"value\\" block-handler-1=\\"input\\"/>\`);
|
||||||
@@ -374,15 +374,15 @@ exports[`t-model directive two inputs in a div alternating with a t-if 1`] = `
|
|||||||
let b2,b3;
|
let b2,b3;
|
||||||
if (ctx['state'].flag) {
|
if (ctx['state'].flag) {
|
||||||
const bExpr1 = ctx['state'];
|
const bExpr1 = ctx['state'];
|
||||||
let attr1 = ctx['state']['text1'];
|
let d1 = ctx['state']['text1'];
|
||||||
let hdlr1 = [(ev) => { bExpr1['text1'] = ev.target.value; }];
|
let d2 = [(ev) => { bExpr1['text1'] = ev.target.value; }];
|
||||||
b2 = block2([attr1, hdlr1]);
|
b2 = block2([d1, d2]);
|
||||||
}
|
}
|
||||||
if (!ctx['state'].flag) {
|
if (!ctx['state'].flag) {
|
||||||
const bExpr2 = ctx['state'];
|
const bExpr2 = ctx['state'];
|
||||||
let attr2 = ctx['state']['text2'];
|
let d3 = ctx['state']['text2'];
|
||||||
let hdlr2 = [(ev) => { bExpr2['text2'] = ev.target.value; }];
|
let d4 = [(ev) => { bExpr2['text2'] = ev.target.value; }];
|
||||||
b3 = block3([attr2, hdlr2]);
|
b3 = block3([d3, d4]);
|
||||||
}
|
}
|
||||||
return block1([], [b2, b3]);
|
return block1([], [b2, b3]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
exports[`t-on t-on expression captured in t-foreach 1`] = `
|
exports[`t-on t-on expression captured in t-foreach 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block3 = createBlock(\`<div><button block-handler-0=\\"click\\">expr</button></div>\`);
|
let block3 = createBlock(\`<div><button block-handler-0=\\"click\\">expr</button></div>\`);
|
||||||
@@ -20,9 +20,9 @@ exports[`t-on t-on expression captured in t-foreach 1`] = `
|
|||||||
let key1 = ctx['val'];
|
let key1 = ctx['val'];
|
||||||
const v1 = ctx['otherState'];
|
const v1 = ctx['otherState'];
|
||||||
const v2 = ctx['iter'];
|
const v2 = ctx['iter'];
|
||||||
let hdlr1 = [()=>v1.vals.push(v2+'_'+v2), ctx];
|
let d1 = [()=>v1.vals.push(v2+'_'+v2), ctx];
|
||||||
setContextValue(ctx, \\"iter\\", ctx['iter']+1);
|
setContextValue(ctx, \\"iter\\", ctx['iter']+1);
|
||||||
c_block2[i1] = withKey(block3([hdlr1]), key1);
|
c_block2[i1] = withKey(block3([d1]), key1);
|
||||||
}
|
}
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
@@ -33,8 +33,8 @@ exports[`t-on t-on expression captured in t-foreach 1`] = `
|
|||||||
exports[`t-on t-on expression in t-foreach 1`] = `
|
exports[`t-on t-on expression in t-foreach 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block3 = createBlock(\`<div><block-text-0/>: <block-text-1/><button block-handler-2=\\"click\\">Expr</button></div>\`);
|
let block3 = createBlock(\`<div><block-text-0/>: <block-text-1/><button block-handler-2=\\"click\\">Expr</button></div>\`);
|
||||||
@@ -46,12 +46,12 @@ exports[`t-on t-on expression in t-foreach 1`] = `
|
|||||||
ctx[\`val\`] = v_block2[i1];
|
ctx[\`val\`] = v_block2[i1];
|
||||||
ctx[\`val_index\`] = i1;
|
ctx[\`val_index\`] = i1;
|
||||||
let key1 = ctx['val'];
|
let key1 = ctx['val'];
|
||||||
let txt1 = ctx['val_index'];
|
let d1 = ctx['val_index'];
|
||||||
let txt2 = ctx['val']+'';
|
let d2 = ctx['val']+'';
|
||||||
const v1 = ctx['otherState'];
|
const v1 = ctx['otherState'];
|
||||||
const v2 = ctx['val'];
|
const v2 = ctx['val'];
|
||||||
let hdlr1 = [()=>v1.vals.push(v2), ctx];
|
let d3 = [()=>v1.vals.push(v2), ctx];
|
||||||
c_block2[i1] = withKey(block3([txt1, txt2, hdlr1]), key1);
|
c_block2[i1] = withKey(block3([d1, d2, d3]), key1);
|
||||||
}
|
}
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
@@ -62,8 +62,8 @@ exports[`t-on t-on expression in t-foreach 1`] = `
|
|||||||
exports[`t-on t-on expression in t-foreach with t-set 1`] = `
|
exports[`t-on t-on expression in t-foreach with t-set 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue, prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block3 = createBlock(\`<div><block-text-0/>: <block-text-1/><button block-handler-2=\\"click\\">Expr</button></div>\`);
|
let block3 = createBlock(\`<div><block-text-0/>: <block-text-1/><button block-handler-2=\\"click\\">Expr</button></div>\`);
|
||||||
@@ -79,13 +79,13 @@ exports[`t-on t-on expression in t-foreach with t-set 1`] = `
|
|||||||
ctx[\`val_index\`] = i1;
|
ctx[\`val_index\`] = i1;
|
||||||
let key1 = ctx['val'];
|
let key1 = ctx['val'];
|
||||||
setContextValue(ctx, \\"bossa\\", ctx['bossa']+'_'+ctx['val_index']);
|
setContextValue(ctx, \\"bossa\\", ctx['bossa']+'_'+ctx['val_index']);
|
||||||
let txt1 = ctx['val_index'];
|
let d1 = ctx['val_index'];
|
||||||
let txt2 = ctx['val']+'';
|
let d2 = ctx['val']+'';
|
||||||
const v1 = ctx['otherState'];
|
const v1 = ctx['otherState'];
|
||||||
const v2 = ctx['val'];
|
const v2 = ctx['val'];
|
||||||
const v3 = ctx['bossa'];
|
const v3 = ctx['bossa'];
|
||||||
let hdlr1 = [()=>v1.vals.push(v2+'_'+v3), ctx];
|
let d3 = [()=>v1.vals.push(v2+'_'+v3), ctx];
|
||||||
c_block2[i1] = withKey(block3([txt1, txt2, hdlr1]), key1);
|
c_block2[i1] = withKey(block3([d1, d2, d3]), key1);
|
||||||
}
|
}
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
@@ -96,8 +96,8 @@ exports[`t-on t-on expression in t-foreach with t-set 1`] = `
|
|||||||
exports[`t-on t-on method call in t-foreach 1`] = `
|
exports[`t-on t-on method call in t-foreach 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { prepareList, withKey } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block3 = createBlock(\`<div><block-text-0/>: <block-text-1/><button block-handler-2=\\"click\\">meth call</button></div>\`);
|
let block3 = createBlock(\`<div><block-text-0/>: <block-text-1/><button block-handler-2=\\"click\\">meth call</button></div>\`);
|
||||||
@@ -109,11 +109,11 @@ exports[`t-on t-on method call in t-foreach 1`] = `
|
|||||||
ctx[\`val\`] = v_block2[i1];
|
ctx[\`val\`] = v_block2[i1];
|
||||||
ctx[\`val_index\`] = i1;
|
ctx[\`val_index\`] = i1;
|
||||||
let key1 = ctx['val'];
|
let key1 = ctx['val'];
|
||||||
let txt1 = ctx['val_index'];
|
let d1 = ctx['val_index'];
|
||||||
let txt2 = ctx['val']+'';
|
let d2 = ctx['val']+'';
|
||||||
const v1 = ctx['val'];
|
const v1 = ctx['val'];
|
||||||
let hdlr1 = [()=>this.addVal(v1), ctx];
|
let d3 = [()=>this.addVal(v1), ctx];
|
||||||
c_block2[i1] = withKey(block3([txt1, txt2, hdlr1]), key1);
|
c_block2[i1] = withKey(block3([d1, d2, d3]), key1);
|
||||||
}
|
}
|
||||||
let b2 = list(c_block2);
|
let b2 = list(c_block2);
|
||||||
return block1([], [b2]);
|
return block1([], [b2]);
|
||||||
@@ -124,7 +124,23 @@ exports[`t-on t-on method call in t-foreach 1`] = `
|
|||||||
exports[`t-on t-on on destroyed components 1`] = `
|
exports[`t-on t-on on destroyed components 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div block-handler-0=\\"click\\"/>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = [ctx['onClick'], ctx];
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`t-on t-on on destroyed components 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -137,17 +153,3 @@ exports[`t-on t-on on destroyed components 1`] = `
|
|||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-on t-on on destroyed components 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div block-handler-0=\\"click\\"/>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let hdlr1 = [ctx['onClick'], ctx];
|
|
||||||
return block1([hdlr1]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -3,7 +3,23 @@
|
|||||||
exports[`t-props basic use 1`] = `
|
exports[`t-props basic use 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let d1 = ctx['props'].a+ctx['props'].b;
|
||||||
|
return block1([d1]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`t-props basic use 2`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -14,24 +30,27 @@ exports[`t-props basic use 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-props basic use 2`] = `
|
exports[`t-props t-props and other props 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].a+ctx['props'].b;
|
let d1 = ctx['props'].a;
|
||||||
return block1([txt1]);
|
let d2 = ctx['props'].b;
|
||||||
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-props t-props and other props 1`] = `
|
exports[`t-props t-props and other props 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><div><block-child-0/></div></div>\`);
|
let block1 = createBlock(\`<div><div><block-child-0/></div></div>\`);
|
||||||
|
|
||||||
@@ -42,25 +61,26 @@ exports[`t-props t-props and other props 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-props t-props and other props 2`] = `
|
exports[`t-props t-props only 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].a;
|
let d1 = ctx['props'].a;
|
||||||
let txt2 = ctx['props'].b;
|
return block1([d1]);
|
||||||
return block1([txt1, txt2]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-props t-props only 1`] = `
|
exports[`t-props t-props only 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><div><block-child-0/></div></div>\`);
|
let block1 = createBlock(\`<div><div><block-child-0/></div></div>\`);
|
||||||
|
|
||||||
@@ -71,24 +91,25 @@ exports[`t-props t-props only 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-props t-props only 2`] = `
|
exports[`t-props t-props with props 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
let block1 = createBlock(\`<div/>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let txt1 = ctx['props'].a;
|
return block1();
|
||||||
return block1([txt1]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-props t-props with props 1`] = `
|
exports[`t-props t-props with props 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
|
||||||
@@ -98,16 +119,3 @@ exports[`t-props t-props with props 1`] = `
|
|||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`t-props t-props with props 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div/>\`);
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return block1();
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -3,27 +3,18 @@
|
|||||||
exports[`t-set slot setted value (with t-set) not accessible with t-esc 1`] = `
|
exports[`t-set slot setted value (with t-set) not accessible with t-esc 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue, capture } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><p><block-text-0/></p><block-child-0/><p><block-text-1/></p></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
||||||
|
|
||||||
function slot1(ctx, node, key = \\"\\") {
|
|
||||||
ctx = Object.create(ctx);
|
|
||||||
ctx[isBoundary] = 1
|
|
||||||
setContextValue(ctx, \\"iter\\", 'inCall');
|
|
||||||
return text('');
|
|
||||||
}
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"iter\\", 'source');
|
let d1 = ctx['iter'];
|
||||||
let txt1 = ctx['iter'];
|
setContextValue(ctx, \\"iter\\", 'called');
|
||||||
const ctx1 = capture(ctx);
|
let d2 = ctx['iter'];
|
||||||
let b2 = component(\`Childcomp\`, {slots: {'default': {__render: slot1, __ctx: ctx1}}}, key + \`__1\`, node, ctx);
|
return block1([d1, d2]);
|
||||||
let txt2 = ctx['iter'];
|
|
||||||
return block1([txt1, txt2], [b2]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -31,162 +22,24 @@ exports[`t-set slot setted value (with t-set) not accessible with t-esc 1`] = `
|
|||||||
exports[`t-set slot setted value (with t-set) not accessible with t-esc 2`] = `
|
exports[`t-set slot setted value (with t-set) not accessible with t-esc 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
let block1 = createBlock(\`<div><p><block-text-0/></p><block-child-0/><p><block-text-1/></p></div>\`);
|
||||||
|
|
||||||
|
function slot2(ctx, node, key) {
|
||||||
|
setContextValue(ctx, \\"iter\\", 'inCall');
|
||||||
|
}
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
let txt1 = ctx['iter'];
|
setContextValue(ctx, \\"iter\\", 'source');
|
||||||
setContextValue(ctx, \\"iter\\", 'called');
|
let d1 = ctx['iter'];
|
||||||
let txt2 = ctx['iter'];
|
|
||||||
return block1([txt1, txt2]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-set slots with a t-set with a component in body 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { capture, isBoundary, withDefault, LazyValue, safeOutput } = helpers;
|
|
||||||
|
|
||||||
function slot1(ctx, node, key = \\"\\") {
|
|
||||||
ctx = Object.create(ctx);
|
|
||||||
ctx[isBoundary] = 1
|
|
||||||
ctx[\`v\`] = new LazyValue(value1, ctx, node);
|
|
||||||
let b3 = text(\` in slot \`);
|
|
||||||
let b4 = safeOutput(ctx['v']);
|
|
||||||
return multi([b3, b4]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function value1(ctx, node, key = \\"\\") {
|
|
||||||
return component(\`C\`, {}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
const ctx1 = capture(ctx);
|
const ctx1 = capture(ctx);
|
||||||
return component(\`Child\`, {slots: {'default': {__render: slot1, __ctx: ctx1}}}, key + \`__2\`, node, ctx);
|
let b2 = component(\`Childcomp\`, {slots: {'default': {__render: slot2, __ctx: ctx1}}}, key + \`__3\`, node, ctx);
|
||||||
}
|
let d2 = ctx['iter'];
|
||||||
}"
|
return block1([d1, d2], [b2]);
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-set slots with a t-set with a component in body 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { callSlot } = helpers;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let b2 = text(\`Child \`);
|
|
||||||
let b3 = callSlot(ctx, node, key, 'default', false, {});
|
|
||||||
return multi([b2, b3]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-set slots with a t-set with a component in body 3`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return text(\`C\`);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-set slots with an t-set with a component in body 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { capture, isBoundary, withDefault, LazyValue, safeOutput } = helpers;
|
|
||||||
|
|
||||||
let block4 = createBlock(\`<div>coffee</div>\`);
|
|
||||||
|
|
||||||
function slot1(ctx, node, key = \\"\\") {
|
|
||||||
ctx = Object.create(ctx);
|
|
||||||
ctx[isBoundary] = 1
|
|
||||||
ctx[\`v\`] = new LazyValue(value1, ctx, node);
|
|
||||||
let b5 = text(\` tea \`);
|
|
||||||
let b6 = safeOutput(ctx['v']);
|
|
||||||
return multi([b5, b6]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function value1(ctx, node, key = \\"\\") {
|
|
||||||
let b3 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
|
||||||
let b4 = block4();
|
|
||||||
return multi([b3, b4]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
const ctx1 = capture(ctx);
|
|
||||||
return component(\`Blorg\`, {slots: {'default': {__render: slot1, __ctx: ctx1}}}, key + \`__2\`, node, ctx);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-set slots with an t-set with a component in body 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { callSlot } = helpers;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let b2 = text(\`Blorg \`);
|
|
||||||
let b3 = callSlot(ctx, node, key, 'default', false, {});
|
|
||||||
return multi([b2, b3]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-set slots with an t-set with a component in body 3`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return text(\`Child\`);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-set slots with an unused t-set with a component in body 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { capture, isBoundary, withDefault, LazyValue } = helpers;
|
|
||||||
|
|
||||||
function slot1(ctx, node, key = \\"\\") {
|
|
||||||
ctx = Object.create(ctx);
|
|
||||||
ctx[isBoundary] = 1
|
|
||||||
ctx[\`v\`] = new LazyValue(value1, ctx, node);
|
|
||||||
return text(\` in slot \`);
|
|
||||||
}
|
|
||||||
|
|
||||||
function value1(ctx, node, key = \\"\\") {
|
|
||||||
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
const ctx1 = capture(ctx);
|
|
||||||
return component(\`Child\`, {slots: {'default': {__render: slot1, __ctx: ctx1}}}, key + \`__2\`, node, ctx);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-set slots with an unused t-set with a component in body 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { callSlot } = helpers;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
let b2 = text(\`Child \`);
|
|
||||||
let b3 = callSlot(ctx, node, key, 'default', false, {});
|
|
||||||
return multi([b2, b3]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -194,18 +47,18 @@ exports[`t-set slots with an unused t-set with a component in body 2`] = `
|
|||||||
exports[`t-set t-set can't alter component even if key in component 1`] = `
|
exports[`t-set t-set can't alter component even if key in component 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><p><block-text-0/></p><p><block-text-1/></p></div>\`);
|
let block1 = createBlock(\`<div><p><block-text-0/></p><p><block-text-1/></p></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
let txt1 = ctx['iter'];
|
let d1 = ctx['iter'];
|
||||||
setContextValue(ctx, \\"iter\\", 5);
|
setContextValue(ctx, \\"iter\\", 5);
|
||||||
let txt2 = ctx['iter'];
|
let d2 = ctx['iter'];
|
||||||
return block1([txt1, txt2]);
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -213,18 +66,18 @@ exports[`t-set t-set can't alter component even if key in component 1`] = `
|
|||||||
exports[`t-set t-set can't alter component if key not in component 1`] = `
|
exports[`t-set t-set can't alter component if key not in component 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><p><block-text-0/></p><p><block-text-1/></p></div>\`);
|
let block1 = createBlock(\`<div><p><block-text-0/></p><p><block-text-1/></p></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
let txt1 = ctx['iter'];
|
let d1 = ctx['iter'];
|
||||||
setContextValue(ctx, \\"iter\\", 5);
|
setContextValue(ctx, \\"iter\\", 5);
|
||||||
let txt2 = ctx['iter'];
|
let d2 = ctx['iter'];
|
||||||
return block1([txt1, txt2]);
|
return block1([d1, d2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -232,8 +85,8 @@ exports[`t-set t-set can't alter component if key not in component 1`] = `
|
|||||||
exports[`t-set t-set in t-if 1`] = `
|
exports[`t-set t-set in t-if 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-child-0/><p><block-text-0/></p></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-child-0/><p><block-text-0/></p></div>\`);
|
||||||
|
|
||||||
@@ -248,8 +101,8 @@ exports[`t-set t-set in t-if 1`] = `
|
|||||||
} else {
|
} else {
|
||||||
setContextValue(ctx, \\"iter\\", 4);
|
setContextValue(ctx, \\"iter\\", 4);
|
||||||
}
|
}
|
||||||
let txt1 = ctx['iter'];
|
let d1 = ctx['iter'];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -257,19 +110,18 @@ exports[`t-set t-set in t-if 1`] = `
|
|||||||
exports[`t-set t-set not altered by child comp 1`] = `
|
exports[`t-set t-set not altered by child comp 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><p><block-text-0/></p><block-child-0/><p><block-text-1/></p></div>\`);
|
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
setContextValue(ctx, \\"iter\\", 'source');
|
let d1 = ctx['iter'];
|
||||||
let txt1 = ctx['iter'];
|
setContextValue(ctx, \\"iter\\", 'called');
|
||||||
let b2 = component(\`Childcomp\`, {}, key + \`__1\`, node, ctx);
|
let d2 = ctx['iter'];
|
||||||
let txt2 = ctx['iter'];
|
return block1([d1, d2]);
|
||||||
return block1([txt1, txt2], [b2]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -277,18 +129,19 @@ exports[`t-set t-set not altered by child comp 1`] = `
|
|||||||
exports[`t-set t-set not altered by child comp 2`] = `
|
exports[`t-set t-set not altered by child comp 2`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
let block1 = createBlock(\`<div><p><block-text-0/></p><block-child-0/><p><block-text-1/></p></div>\`);
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
ctx = Object.create(ctx);
|
ctx = Object.create(ctx);
|
||||||
ctx[isBoundary] = 1
|
ctx[isBoundary] = 1
|
||||||
let txt1 = ctx['iter'];
|
setContextValue(ctx, \\"iter\\", 'source');
|
||||||
setContextValue(ctx, \\"iter\\", 'called');
|
let d1 = ctx['iter'];
|
||||||
let txt2 = ctx['iter'];
|
let b2 = component(\`Childcomp\`, {}, key + \`__1\`, node, ctx);
|
||||||
return block1([txt1, txt2]);
|
let d2 = ctx['iter'];
|
||||||
|
return block1([d1, d2], [b2]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
@@ -296,8 +149,8 @@ exports[`t-set t-set not altered by child comp 2`] = `
|
|||||||
exports[`t-set t-set outside modified in t-if 1`] = `
|
exports[`t-set t-set outside modified in t-if 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-child-0/><p><block-text-0/></p></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-child-0/><p><block-text-0/></p></div>\`);
|
||||||
|
|
||||||
@@ -313,64 +166,8 @@ exports[`t-set t-set outside modified in t-if 1`] = `
|
|||||||
} else {
|
} else {
|
||||||
setContextValue(ctx, \\"iter\\", 4);
|
setContextValue(ctx, \\"iter\\", 4);
|
||||||
}
|
}
|
||||||
let txt1 = ctx['iter'];
|
let d1 = ctx['iter'];
|
||||||
return block1([txt1]);
|
return block1([d1]);
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-set t-set with a component in body 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { isBoundary, withDefault, LazyValue, safeOutput } = helpers;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><div><block-child-0/></div></div>\`);
|
|
||||||
|
|
||||||
function value1(ctx, node, key = \\"\\") {
|
|
||||||
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
ctx = Object.create(ctx);
|
|
||||||
ctx[isBoundary] = 1
|
|
||||||
ctx[\`v\`] = new LazyValue(value1, ctx, node);
|
|
||||||
let b3 = safeOutput(ctx['v']);
|
|
||||||
return block1([], [b3]);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-set t-set with a component in body 2`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
return text(\`Child\`);
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`t-set t-set with something in body 1`] = `
|
|
||||||
"function anonymous(bdom, helpers
|
|
||||||
) {
|
|
||||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
||||||
let { isBoundary, withDefault, LazyValue, safeOutput } = helpers;
|
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><div><block-child-0/></div></div>\`);
|
|
||||||
let block2 = createBlock(\`<p>coucou</p>\`);
|
|
||||||
|
|
||||||
function value1(ctx, node, key = \\"\\") {
|
|
||||||
return block2();
|
|
||||||
}
|
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
|
||||||
ctx = Object.create(ctx);
|
|
||||||
ctx[isBoundary] = 1
|
|
||||||
ctx[\`v\`] = new LazyValue(value1, ctx, node);
|
|
||||||
let b3 = safeOutput(ctx['v']);
|
|
||||||
return block1([], [b3]);
|
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { App, Component } from "../../src";
|
||||||
|
import { status } from "../../src/component/status";
|
||||||
|
import { xml } from "../../src/tags";
|
||||||
|
import { makeTestFixture, snapshotEverything } from "../helpers";
|
||||||
|
|
||||||
|
let fixture: HTMLElement;
|
||||||
|
|
||||||
|
snapshotEverything();
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = makeTestFixture();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("app", () => {
|
||||||
|
test("destroy remove the widget from the DOM", async () => {
|
||||||
|
class SomeComponent extends Component {
|
||||||
|
static template = xml`<div/>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const app = new App(SomeComponent);
|
||||||
|
const comp = await app.mount(fixture);
|
||||||
|
const el = comp.el!;
|
||||||
|
expect(document.contains(el)).toBe(true);
|
||||||
|
app.destroy();
|
||||||
|
expect(document.contains(el)).toBe(false);
|
||||||
|
expect(status(comp)).toBe("destroyed");
|
||||||
|
});
|
||||||
|
});
|
||||||
+32
-100
@@ -1,5 +1,6 @@
|
|||||||
import { App, Component, mount, status, useState, xml } from "../../src";
|
import { App, Component, mount, status, useState } from "../../src";
|
||||||
import { elem, makeTestFixture, nextTick, snapshotEverything, useLogLifecycle } from "../helpers";
|
import { xml } from "../../src/tags";
|
||||||
|
import { makeTestFixture, nextTick, snapshotEverything } from "../helpers";
|
||||||
import { markup } from "../../src/utils";
|
import { markup } from "../../src/utils";
|
||||||
|
|
||||||
let fixture: HTMLElement;
|
let fixture: HTMLElement;
|
||||||
@@ -19,7 +20,20 @@ describe("basics", () => {
|
|||||||
const component = await mount(Test, fixture);
|
const component = await mount(Test, fixture);
|
||||||
|
|
||||||
expect(fixture.innerHTML).toBe("<span>simple vnode</span>");
|
expect(fixture.innerHTML).toBe("<span>simple vnode</span>");
|
||||||
expect(elem(component)).toEqual(fixture.querySelector("span"));
|
expect(component.el).toEqual(fixture.querySelector("span"));
|
||||||
|
});
|
||||||
|
|
||||||
|
test("has no el after creation", async () => {
|
||||||
|
let el: any = null;
|
||||||
|
class Test extends Component {
|
||||||
|
static template = xml`<span>simple</span>`;
|
||||||
|
setup() {
|
||||||
|
el = this.el;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await mount(Test, fixture);
|
||||||
|
expect(el).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("cannot mount on a documentFragment", async () => {
|
test("cannot mount on a documentFragment", async () => {
|
||||||
@@ -41,11 +55,11 @@ describe("basics", () => {
|
|||||||
static template = xml`<span><t t-esc="props.value"/></span>`;
|
static template = xml`<span><t t-esc="props.value"/></span>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const app = new App(Test, { props: { value: 3 } });
|
const app = new App(Test, { value: 3 });
|
||||||
const component = await app.mount(fixture);
|
const component = await app.mount(fixture);
|
||||||
|
|
||||||
expect(fixture.innerHTML).toBe("<span>3</span>");
|
expect(fixture.innerHTML).toBe("<span>3</span>");
|
||||||
expect(elem(component)).toEqual(fixture.querySelector("span"));
|
expect(component.el).toEqual(fixture.querySelector("span"));
|
||||||
});
|
});
|
||||||
|
|
||||||
test("can mount a component with just some text", async () => {
|
test("can mount a component with just some text", async () => {
|
||||||
@@ -56,7 +70,7 @@ describe("basics", () => {
|
|||||||
const component = await mount(Test, fixture);
|
const component = await mount(Test, fixture);
|
||||||
|
|
||||||
expect(fixture.innerHTML).toBe("just text");
|
expect(fixture.innerHTML).toBe("just text");
|
||||||
expect(elem(component)).toBeInstanceOf(Text);
|
expect(component.el).toBeInstanceOf(Text);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("can mount a component with no text", async () => {
|
test("can mount a component with no text", async () => {
|
||||||
@@ -67,7 +81,7 @@ describe("basics", () => {
|
|||||||
const component = await mount(Test, fixture);
|
const component = await mount(Test, fixture);
|
||||||
|
|
||||||
expect(fixture.innerHTML).toBe("");
|
expect(fixture.innerHTML).toBe("");
|
||||||
expect(elem(component)).toBeInstanceOf(Text);
|
expect(component.el).toBeInstanceOf(Text);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("can mount a simple component with multiple roots", async () => {
|
test("can mount a simple component with multiple roots", async () => {
|
||||||
@@ -78,7 +92,7 @@ describe("basics", () => {
|
|||||||
const component = await mount(Test, fixture);
|
const component = await mount(Test, fixture);
|
||||||
|
|
||||||
expect(fixture.innerHTML).toBe("<span></span><div></div>");
|
expect(fixture.innerHTML).toBe("<span></span><div></div>");
|
||||||
expect(elem(component).tagName).toBe("SPAN");
|
expect((component.el as any).tagName).toBe("SPAN");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("component with dynamic content can be updated", async () => {
|
test("component with dynamic content can be updated", async () => {
|
||||||
@@ -92,8 +106,7 @@ describe("basics", () => {
|
|||||||
expect(fixture.innerHTML).toBe("<span>1</span>");
|
expect(fixture.innerHTML).toBe("<span>1</span>");
|
||||||
|
|
||||||
component.value = 2;
|
component.value = 2;
|
||||||
component.render();
|
await component.render();
|
||||||
await nextTick();
|
|
||||||
expect(fixture.innerHTML).toBe("<span>2</span>");
|
expect(fixture.innerHTML).toBe("<span>2</span>");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -110,8 +123,7 @@ describe("basics", () => {
|
|||||||
|
|
||||||
expect(fixture.innerHTML).toBe("onetwothree");
|
expect(fixture.innerHTML).toBe("onetwothree");
|
||||||
component.items = ["two", "three", "one"];
|
component.items = ["two", "three", "one"];
|
||||||
component.render();
|
await component.render();
|
||||||
await nextTick();
|
|
||||||
expect(fixture.innerHTML).toBe("twothreeone");
|
expect(fixture.innerHTML).toBe("twothreeone");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -125,15 +137,16 @@ describe("basics", () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const app = new App(Test, { props: p });
|
const app = new App(Test, p);
|
||||||
await app.mount(fixture);
|
await app.mount(fixture);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("some simple sanity checks (el/status)", async () => {
|
test("some simple sanity checks (el/status)", async () => {
|
||||||
expect.assertions(3);
|
expect.assertions(4);
|
||||||
class Test extends Component {
|
class Test extends Component {
|
||||||
static template = xml`<span>simple vnode</span>`;
|
static template = xml`<span>simple vnode</span>`;
|
||||||
setup() {
|
setup() {
|
||||||
|
expect(this.el).toBe(undefined);
|
||||||
expect(status(this)).toBe("new");
|
expect(status(this)).toBe("new");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -245,8 +258,7 @@ describe("basics", () => {
|
|||||||
const test = await mount(Test, fixture);
|
const test = await mount(Test, fixture);
|
||||||
expect(fixture.innerHTML).toBe("<div>3</div>");
|
expect(fixture.innerHTML).toBe("<div>3</div>");
|
||||||
test.value = 5;
|
test.value = 5;
|
||||||
test.render();
|
await test.render();
|
||||||
await nextTick();
|
|
||||||
expect(fixture.innerHTML).toBe("<div>5</div>");
|
expect(fixture.innerHTML).toBe("<div>5</div>");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -365,14 +377,13 @@ describe("basics", () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await mount(Counter, fixture);
|
const counter = await mount(Counter, fixture);
|
||||||
expect(fixture.innerHTML).toBe("<div>0<button>Inc</button></div>");
|
expect(fixture.innerHTML).toBe("<div>0<button>Inc</button></div>");
|
||||||
const button = fixture.getElementsByTagName("button")[0];
|
const button = (<HTMLElement>counter.el).getElementsByTagName("button")[0];
|
||||||
button.click();
|
button.click();
|
||||||
await nextTick();
|
await nextTick();
|
||||||
expect(fixture.innerHTML).toBe("<div>1<button>Inc</button></div>");
|
expect(fixture.innerHTML).toBe("<div>1<button>Inc</button></div>");
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: rename
|
// TODO: rename
|
||||||
test("rerendering a widget with a sub widget", async () => {
|
test("rerendering a widget with a sub widget", async () => {
|
||||||
class Counter extends Component {
|
class Counter extends Component {
|
||||||
@@ -479,7 +490,7 @@ describe("basics", () => {
|
|||||||
}
|
}
|
||||||
const widget = await mount(SomeComponent, fixture);
|
const widget = await mount(SomeComponent, fixture);
|
||||||
expect(fixture.innerHTML).toBe(`<div></div>`);
|
expect(fixture.innerHTML).toBe(`<div></div>`);
|
||||||
fixture.querySelector("div")!.appendChild(document.createElement("span"));
|
widget.el!.appendChild(document.createElement("span"));
|
||||||
expect(fixture.innerHTML).toBe(`<div><span></span></div>`);
|
expect(fixture.innerHTML).toBe(`<div><span></span></div>`);
|
||||||
await widget.render();
|
await widget.render();
|
||||||
expect(fixture.innerHTML).toBe(`<div><span></span></div>`);
|
expect(fixture.innerHTML).toBe(`<div><span></span></div>`);
|
||||||
@@ -492,7 +503,7 @@ describe("basics", () => {
|
|||||||
}
|
}
|
||||||
const comp = await mount(SomeComponent, fixture);
|
const comp = await mount(SomeComponent, fixture);
|
||||||
expect(fixture.innerHTML).toBe(`<div><h1>h1</h1><span>1</span></div>`);
|
expect(fixture.innerHTML).toBe(`<div><h1>h1</h1><span>1</span></div>`);
|
||||||
fixture.querySelector("h1")!.appendChild(document.createElement("p"));
|
(comp.el! as any).querySelector("h1")!.appendChild(document.createElement("p"));
|
||||||
expect(fixture.innerHTML).toBe("<div><h1>h1<p></p></h1><span>1</span></div>");
|
expect(fixture.innerHTML).toBe("<div><h1>h1<p></p></h1><span>1</span></div>");
|
||||||
|
|
||||||
comp.state.value++;
|
comp.state.value++;
|
||||||
@@ -819,16 +830,6 @@ describe("mount targets", () => {
|
|||||||
expect(fixture.innerHTML).toBe("<span></span><div>app</div>");
|
expect(fixture.innerHTML).toBe("<span></span><div>app</div>");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("mount function: can mount a component (with default position='last-child')", async () => {
|
|
||||||
class Root extends Component {
|
|
||||||
static template = xml`<div>app</div>`;
|
|
||||||
}
|
|
||||||
const span = document.createElement("span");
|
|
||||||
fixture.appendChild(span);
|
|
||||||
await mount(Root, fixture, { position: "last-child" });
|
|
||||||
expect(fixture.innerHTML).toBe("<span></span><div>app</div>");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("default mount option is 'last-child'", async () => {
|
test("default mount option is 'last-child'", async () => {
|
||||||
class Root extends Component {
|
class Root extends Component {
|
||||||
static template = xml`<div>app</div>`;
|
static template = xml`<div>app</div>`;
|
||||||
@@ -900,73 +901,4 @@ describe("t-out in components", () => {
|
|||||||
"<div><b>one</b><b>one</b><b>two</b><b>two</b><b>tree</b><b>tree</b></div>"
|
"<div><b>one</b><b>one</b><b>two</b><b>two</b><b>tree</b><b>tree</b></div>"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("component children doesn't leak (if case)", async () => {
|
|
||||||
class Child extends Component {
|
|
||||||
static template = xml`<div />`;
|
|
||||||
setup() {
|
|
||||||
useLogLifecycle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class Parent extends Component {
|
|
||||||
static components = { Child };
|
|
||||||
static template = xml`<Child t-if="ifVar" />`;
|
|
||||||
ifVar = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const parent = await mount(Parent, fixture);
|
|
||||||
expect(Object.keys(parent.__owl__.children).length).toStrictEqual(1);
|
|
||||||
expect([
|
|
||||||
"Child:setup",
|
|
||||||
"Child:willStart",
|
|
||||||
"Child:willRender",
|
|
||||||
"Child:rendered",
|
|
||||||
"Child:mounted",
|
|
||||||
]).toBeLogged();
|
|
||||||
|
|
||||||
parent.ifVar = false;
|
|
||||||
parent.render();
|
|
||||||
await nextTick();
|
|
||||||
expect(Object.keys(parent.__owl__.children).length).toStrictEqual(0);
|
|
||||||
expect(["Child:willUnmount", "Child:willDestroy"]).toBeLogged();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("component children doesn't leak (t-key case)", async () => {
|
|
||||||
// This test should encompass the t-foreach and t-call cases too (because they also use a flavor of some key)
|
|
||||||
class Child extends Component {
|
|
||||||
static template = xml`<div />`;
|
|
||||||
setup() {
|
|
||||||
useLogLifecycle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class Parent extends Component {
|
|
||||||
static components = { Child };
|
|
||||||
static template = xml`<Child t-key="keyVar" />`;
|
|
||||||
keyVar = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const parent = await mount(Parent, fixture);
|
|
||||||
expect(Object.keys(parent.__owl__.children).length).toStrictEqual(1);
|
|
||||||
expect([
|
|
||||||
"Child:setup",
|
|
||||||
"Child:willStart",
|
|
||||||
"Child:willRender",
|
|
||||||
"Child:rendered",
|
|
||||||
"Child:mounted",
|
|
||||||
]).toBeLogged();
|
|
||||||
|
|
||||||
parent.keyVar = 2;
|
|
||||||
parent.render();
|
|
||||||
await nextTick();
|
|
||||||
expect(Object.keys(parent.__owl__.children).length).toStrictEqual(1);
|
|
||||||
expect([
|
|
||||||
"Child:setup",
|
|
||||||
"Child:willStart",
|
|
||||||
"Child:willRender",
|
|
||||||
"Child:rendered",
|
|
||||||
"Child:willUnmount",
|
|
||||||
"Child:willDestroy",
|
|
||||||
"Child:mounted",
|
|
||||||
]).toBeLogged();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
+907
-1374
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,7 @@ describe("env handling", () => {
|
|||||||
class Test extends Component {
|
class Test extends Component {
|
||||||
static template = xml`<div/>`;
|
static template = xml`<div/>`;
|
||||||
}
|
}
|
||||||
const component = await new App(Test, { env }).mount(fixture);
|
const component = await new App(Test).configure({ env }).mount(fixture);
|
||||||
expect(Object.isFrozen(component.env)).toBeTruthy();
|
expect(Object.isFrozen(component.env)).toBeTruthy();
|
||||||
expect(component.env).toEqual({ foo: 42, bar: { value: 42 } });
|
expect(component.env).toEqual({ foo: 42, bar: { value: 42 } });
|
||||||
expect(() => {
|
expect(() => {
|
||||||
@@ -47,7 +47,7 @@ describe("env handling", () => {
|
|||||||
static components = { Child };
|
static components = { Child };
|
||||||
}
|
}
|
||||||
|
|
||||||
await new App(Test, { env }).mount(fixture);
|
await new App(Test).configure({ env }).mount(fixture);
|
||||||
expect(child.env).toEqual(env);
|
expect(child.env).toEqual(env);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user