mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fe176f13a5 | |||
| 871dad6a13 | |||
| b620502a0f |
@@ -107,7 +107,7 @@ is necessary, since Owl needs to react to a change in state.
|
|||||||
### `useRef`
|
### `useRef`
|
||||||
|
|
||||||
The `useRef` hook is useful when we need a way to interact with some inside part
|
The `useRef` hook is useful when we need a way to interact with some inside part
|
||||||
of a component, rendered by Owl. It only work on a html element tagged by the
|
of a component, rendered by Owl. It only work on a HTML element tagged by the
|
||||||
`t-ref` directive:
|
`t-ref` directive:
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
@@ -227,12 +227,12 @@ function useSomething() {
|
|||||||
|
|
||||||
This hook will run a callback when a component is mounted and patched, and
|
This hook will run a callback when a component is mounted and patched, and
|
||||||
will run a cleanup function before patching and before unmounting the
|
will run a cleanup function before patching and before unmounting the
|
||||||
the component (only if some dependencies have changed).
|
component (only if some dependencies have changed).
|
||||||
|
|
||||||
It has almost the same API as the React `useEffect` hook, except that the dependencies
|
It has almost the same API as the React `useEffect` hook, except that the dependencies
|
||||||
are defined by a function instead of just the dependencies.
|
are defined by a function instead of just the dependencies.
|
||||||
|
|
||||||
The `useEffect` hook takes two function: the effect function and the dependency
|
The `useEffect` hook takes two functions: the effect function and the dependency
|
||||||
function. The effect function perform some task and return (optionally) a cleanup
|
function. The effect function perform some task and return (optionally) a cleanup
|
||||||
function. The dependency function returns a list of dependencies, these dependencies
|
function. The dependency function returns a list of dependencies, these dependencies
|
||||||
are passed as parameters in the effect function . If any of these
|
are passed as parameters in the effect function . If any of these
|
||||||
|
|||||||
@@ -680,7 +680,7 @@ class MyComponent extends Component {
|
|||||||
mount(MyComponent, document.body);
|
mount(MyComponent, document.body);
|
||||||
```
|
```
|
||||||
|
|
||||||
This function simply generates a unique string id, and register the template
|
This function simply generates an unique string id, and register the template
|
||||||
under that id in the internals of Owl, then return the id.
|
under that id in the internals of Owl, then return the id.
|
||||||
|
|
||||||
## Rendering svg
|
## Rendering svg
|
||||||
|
|||||||
+15
-6
@@ -3850,7 +3850,16 @@ class CodeTarget {
|
|||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const TRANSLATABLE_ATTRS = ["label", "title", "placeholder", "alt"];
|
const TRANSLATABLE_ATTRS = [
|
||||||
|
"alt",
|
||||||
|
"aria-label",
|
||||||
|
"aria-placeholder",
|
||||||
|
"aria-roledescription",
|
||||||
|
"aria-valuetext",
|
||||||
|
"label",
|
||||||
|
"placeholder",
|
||||||
|
"title",
|
||||||
|
];
|
||||||
const translationRE = /^(\s*)([\s\S]+?)(\s*)$/;
|
const translationRE = /^(\s*)([\s\S]+?)(\s*)$/;
|
||||||
class CodeGenerator {
|
class CodeGenerator {
|
||||||
constructor(ast, options) {
|
constructor(ast, options) {
|
||||||
@@ -4968,11 +4977,11 @@ function parseNode(node, ctx) {
|
|||||||
parseTPortal(node, ctx) ||
|
parseTPortal(node, ctx) ||
|
||||||
parseTCall(node, ctx) ||
|
parseTCall(node, ctx) ||
|
||||||
parseTCallBlock(node) ||
|
parseTCallBlock(node) ||
|
||||||
|
parseTTranslation(node, ctx) ||
|
||||||
|
parseTTranslationContext(node, ctx) ||
|
||||||
parseTEscNode(node, ctx) ||
|
parseTEscNode(node, ctx) ||
|
||||||
parseTOutNode(node, ctx) ||
|
parseTOutNode(node, ctx) ||
|
||||||
parseTKey(node, ctx) ||
|
parseTKey(node, ctx) ||
|
||||||
parseTTranslation(node, ctx) ||
|
|
||||||
parseTTranslationContext(node, ctx) ||
|
|
||||||
parseTSlot(node, ctx) ||
|
parseTSlot(node, ctx) ||
|
||||||
parseComponent(node, ctx) ||
|
parseComponent(node, ctx) ||
|
||||||
parseDOMNode(node, ctx) ||
|
parseDOMNode(node, ctx) ||
|
||||||
@@ -5758,7 +5767,7 @@ function compile(template, options = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// do not modify manually. This file is generated by the release script.
|
// do not modify manually. This file is generated by the release script.
|
||||||
const version = "2.7.0";
|
const version = "2.8.0";
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Scheduler
|
// Scheduler
|
||||||
@@ -6229,6 +6238,6 @@ TemplateSet.prototype._compileTemplate = function _compileTemplate(name, templat
|
|||||||
export { App, Component, EventBus, OwlError, __info__, batched, blockDom, htmlEscape, loadFile, markRaw, markup, mount, onError, onMounted, onPatched, onRendered, onWillDestroy, onWillPatch, onWillRender, onWillStart, onWillUnmount, onWillUpdateProps, reactive, status, toRaw, useChildSubEnv, useComponent, useEffect, useEnv, useExternalListener, useRef, useState, useSubEnv, validate, validateType, whenReady, xml };
|
export { App, Component, EventBus, OwlError, __info__, batched, blockDom, htmlEscape, loadFile, markRaw, markup, mount, onError, onMounted, onPatched, onRendered, onWillDestroy, onWillPatch, onWillRender, onWillStart, onWillUnmount, onWillUpdateProps, reactive, status, toRaw, useChildSubEnv, useComponent, useEffect, useEnv, useExternalListener, useRef, useState, useSubEnv, validate, validateType, whenReady, xml };
|
||||||
|
|
||||||
|
|
||||||
__info__.date = '2025-03-26T12:58:40.935Z';
|
__info__.date = '2025-06-30T12:46:06.424Z';
|
||||||
__info__.hash = 'e788e36';
|
__info__.hash = 'b620502';
|
||||||
__info__.url = 'https://github.com/odoo/owl';
|
__info__.url = 'https://github.com/odoo/owl';
|
||||||
|
|||||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@odoo/owl",
|
"name": "@odoo/owl",
|
||||||
"version": "2.7.0",
|
"version": "2.8.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@odoo/owl",
|
"name": "@odoo/owl",
|
||||||
"version": "2.7.0",
|
"version": "2.8.0",
|
||||||
"description": "Odoo Web Library (OWL)",
|
"description": "Odoo Web Library (OWL)",
|
||||||
"main": "dist/owl.cjs.js",
|
"main": "dist/owl.cjs.js",
|
||||||
"module": "dist/owl.es.js",
|
"module": "dist/owl.es.js",
|
||||||
|
|||||||
@@ -253,11 +253,11 @@ function parseNode(node: Node, ctx: ParsingContext): AST | null {
|
|||||||
parseTPortal(node, ctx) ||
|
parseTPortal(node, ctx) ||
|
||||||
parseTCall(node, ctx) ||
|
parseTCall(node, ctx) ||
|
||||||
parseTCallBlock(node, ctx) ||
|
parseTCallBlock(node, ctx) ||
|
||||||
|
parseTTranslation(node, ctx) ||
|
||||||
|
parseTTranslationContext(node, ctx) ||
|
||||||
parseTEscNode(node, ctx) ||
|
parseTEscNode(node, ctx) ||
|
||||||
parseTOutNode(node, ctx) ||
|
parseTOutNode(node, ctx) ||
|
||||||
parseTKey(node, ctx) ||
|
parseTKey(node, ctx) ||
|
||||||
parseTTranslation(node, ctx) ||
|
|
||||||
parseTTranslationContext(node, ctx) ||
|
|
||||||
parseTSlot(node, ctx) ||
|
parseTSlot(node, ctx) ||
|
||||||
parseComponent(node, ctx) ||
|
parseComponent(node, ctx) ||
|
||||||
parseDOMNode(node, ctx) ||
|
parseDOMNode(node, ctx) ||
|
||||||
|
|||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
// do not modify manually. This file is generated by the release script.
|
// do not modify manually. This file is generated by the release script.
|
||||||
export const version = "2.7.0";
|
export const version = "2.8.0";
|
||||||
|
|||||||
@@ -1971,6 +1971,54 @@ describe("qweb parser", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('t-translation="off": interaction with t-esc', async () => {
|
||||||
|
expect(parse(`<span t-esc="a" t-translation="off"/>`)).toEqual({
|
||||||
|
type: ASTType.TTranslation,
|
||||||
|
content: {
|
||||||
|
attrs: null,
|
||||||
|
attrsTranslationCtx: null,
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
defaultValue: "",
|
||||||
|
expr: "a",
|
||||||
|
type: ASTType.TEsc,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
dynamicTag: null,
|
||||||
|
model: null,
|
||||||
|
ns: null,
|
||||||
|
on: null,
|
||||||
|
ref: null,
|
||||||
|
tag: "span",
|
||||||
|
type: ASTType.DomNode,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('t-translation="off": interaction with t-out', async () => {
|
||||||
|
expect(parse(`<span t-out="a" t-translation="off"/>`)).toEqual({
|
||||||
|
type: ASTType.TTranslation,
|
||||||
|
content: {
|
||||||
|
attrs: null,
|
||||||
|
attrsTranslationCtx: null,
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
body: null,
|
||||||
|
expr: "a",
|
||||||
|
type: ASTType.TOut,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
dynamicTag: null,
|
||||||
|
model: null,
|
||||||
|
ns: null,
|
||||||
|
on: null,
|
||||||
|
ref: null,
|
||||||
|
tag: "span",
|
||||||
|
type: ASTType.DomNode,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// t-translation-context
|
// t-translation-context
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -2008,6 +2056,56 @@ describe("qweb parser", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("t-translation-context: interaction with t-esc", async () => {
|
||||||
|
expect(parse(`<span t-esc="a" t-translation-context="fr"/>`)).toEqual({
|
||||||
|
type: ASTType.TTranslationContext,
|
||||||
|
content: {
|
||||||
|
attrs: null,
|
||||||
|
attrsTranslationCtx: null,
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
defaultValue: "",
|
||||||
|
expr: "a",
|
||||||
|
type: ASTType.TEsc,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
dynamicTag: null,
|
||||||
|
model: null,
|
||||||
|
ns: null,
|
||||||
|
on: null,
|
||||||
|
ref: null,
|
||||||
|
tag: "span",
|
||||||
|
type: ASTType.DomNode,
|
||||||
|
},
|
||||||
|
translationCtx: "fr",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test("t-translation-context: interaction with t-out", async () => {
|
||||||
|
expect(parse(`<span t-out="a" t-translation-context="fr"/>`)).toEqual({
|
||||||
|
type: ASTType.TTranslationContext,
|
||||||
|
content: {
|
||||||
|
attrs: null,
|
||||||
|
attrsTranslationCtx: null,
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
body: null,
|
||||||
|
expr: "a",
|
||||||
|
type: ASTType.TOut,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
dynamicTag: null,
|
||||||
|
model: null,
|
||||||
|
ns: null,
|
||||||
|
on: null,
|
||||||
|
ref: null,
|
||||||
|
tag: "span",
|
||||||
|
type: ASTType.DomNode,
|
||||||
|
},
|
||||||
|
translationCtx: "fr",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// t-translation-context-attr
|
// t-translation-context-attr
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user