summaryrefslogtreecommitdiff
path: root/addons/web/static/lib/qweb/qweb2.js
AgeCommit message (Collapse)Author
2020-07-10[FIX] web: qweb old inheritance mechanismAaron Bohy
Before this commit, defining a extension of a template by using the combination of directives 't-name' and 't-extend' ignored potential extensions that could have been defined beforehand. For instance, let's assume the following templates. ```xml <t t-name="a"> <div><span>1</span></div> </t> <t t-extend="a"> <t t-jquery="span" t-operation="replace"> <span>2</span> </t> </t> <t t-name="b" t-extend="a"> <t t-jquery="div" t-operation="append"> <span>b</span> </t> </t> ``` Rendering template "b" displayed "1b" whereas we would expect "2b". Moreover, when the extended template is itself an extension of another template: ```xml <t t-name="a"> <div><span>a</span></div> </t> <t t-name="b" t-extend="a"> <t t-jquery="div" t-operation="append"> <span>b</span> </t> </t> <t t-name="c" t-extend="b"> <t t-jquery="div" t-operation="append"> <span>c</span> </t> </t> ``` Rendering template "a" displayed "a", template "b" displayed "ab", but template "c" displayed "ac", whereas we would expect "abc". With this commit, other extensions done to a template are kept when a new extension is defined. It relies on the templates order, and takes into account all extensions that have *already* been defined. This is exactly how the new qweb inheritance mechanism (using 't-inherit' and 't-inherit-mode') behaves. closes odoo/odoo#54315 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2020-02-24[FIX] qweb2: ignore comments between branching directivesLucas Perais (lpe)
Have a template of that form: ```xml <t t-if=""/> <!-- Comment --> <t t-elif=""/> ``` Before this commit, both python and JS crashed because any type of node between branching directive was forbidden After this commit, Comments are just ignored and removed, while actual template nodes are still forbidden between branching directives There is no crash anymore closes odoo/odoo#45899 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2019-03-19[MERGE] forward port branch 12.0 up to 82c4393fd02Christophe Simonis
2019-03-18[MERGE] forward port branch saas-11.3 up to 4e39328a76aChristophe Simonis
2019-03-18[MERGE] forward port branch saas-15 up to c6353942ffdChristophe Simonis
2019-03-12[FIX] web: qweb2: allow null values in a foreach iterationDenis Vermylen
Before this commit iteration in a t-foreach containing null or undefined values crashed because they have no attributes. closes odoo/odoo#31828 Signed-off-by: Fabien Meghazi <amigrave@users.noreply.github.com>
2019-01-30[FIX] web: support full attribute syntaxMartin Trigaux
Only the syntax <t t-operation="attributes"> <attribute name="foo">bar</attribute> </t> was currently supported for attributes while the syntax <t t-operation="attributes"> <attribute name="foo" value="bar" /> </t> Is also correct and supported server side. Using value instead of the node content is needed to avoid translating the node while it is parsed by babel to extract translatable content
2018-08-13[FIX] web: fix JavaScript qweb and activate testsChristophe Matthieu
Fix the issue of the t-esc display the content before the tag. Activate qweb qunit test (same test for the JavaScript and python) Use the same behavior as python: keep attributes order, and display content as default value when the variable is falsy.
2018-06-22[IMP] Improve compatibility with screen readers (accessibility) (#24574)kujiu
Today, Odoo is really tricky to use without seeing the screen, it must be improved to be usable. This PR forbid to use labels without a "for" attribute, add some title, rule and aria attributes in HTML. With that, Odoo will be fully usable with a screen reader. * [IMP] Labels must have a for attribute. Improve accessibility. * [IMP] Better error message when trying to read a missing cached value * [FIX] Add some aria-label and title attributes for screen readers. * [FIX] Template name is not included in the error message in case of SyntaxError in QWeb * [FIX] Improve the Tour failed at step error message to be more explicit. * [IMP] Add aria-labels * [FIX] Add missing aria-label on failing test * [IMP] aria-hidden means hidden. Fix all bad aria-hidden and hide aria-hidden for all. * [IMP] Color names on kanban views and many2many tags * [IMP] Add some checks on views for accessibility. * [IMP] Add `alt` attribute on `img` tags. * [IMP] Add aria-label and title on non-described icons * [IMP] Add button role to widgets with btn class * [IMP] Translate aria and formatted attributes. * [IMP] Remove wrong aria-labelledby * [IMP] Add menu role on dropdowns * [IMP] Buttons must be focusable * [IMP] Add aria attributes on progress bars * [IMP] Improve accessibility of basic widgets * [IMP] Change main layout to more semantic tags * [IMP] Add menuitem role when missing * [IMP] Remove wrong role='presentation' * [IMP] Improve accessibility of tab panels * [IMP] Add aria-invalid on invalid fields * [IMP] Add aria-sort on ordered columns * [IMP] Add role on alerts * [IMP] Use dialog role, header, main and footer tags for modals * [IMP] Add labels on o_status * [IMP] Improve accessibility of kanban view with feeds and articles * [IMP] Add alerts in case of new messages * [IMP] Add widget, navigation or img role to aria-labelled items
2018-03-05[FIX] web: qweb: load template with non-http xhrAdrien Dieudonne
Since we are able to lazy load Qweb templates, there was an issue to generate Awesome Timesheet iOS native app with Cordova properly. It seems that under Cordova, iOS always returns 0 for the status on a xml http request object. The problem is that native applications are requesting a local file from something that isn't a webserver. The local file is delivered with no http headers that means no "200 OK" header and no "404 Not Found" errors. In this case, the request is still be completing as intended even if the status code used by browsers is 0. For more info, see: https://developer.mozilla.org/fr/docs/Web/API/XMLHttpRequest https://bugzilla.mozilla.org/show_bug.cgi?id=331610
2017-10-10Revert "[FIX] qwebjs: add tests to test suite"Xavier Morel
2017-10-10[FIX] web: make qwebjs tests pass againXavier Morel
A bunch of features had been added to the qweb test files and qwebjs did not pass them as features were either implemented differently or not implemented at all: * Fixed wonky and not cross-impl tests - added ``not`` word replacemenet to qwebjs as I wasn't sure how to handle that one cross-impl * fixed t-esc/t-raw to render content *inside* the host node e.g. span@t-esc should render as <span>{contents of esc}</span> * added fallback to body content if t-esc/t-raw yields an empty result * process t-att in order with t-att-* and t-attf-* rather than before them both * suppress attribute generation entirely in case of falsy value
2017-05-04[IMP] web: extend qweb to allow dynamic templates in t-callChristophe Matthieu
Before this change the t-call can use only receive a literal as parameters: <t t-call="template.name17" /> This call render the template 'template.name17' with the current context. Now, we can defined an expression with braces (same syntax that t-attf): <t t-call="template.name{{ 10 + 7 }}" /> This call render the template 'template.name17' with the current context. This change allows for greater flexibility for applications using qweb. (The performance due to this change is unchanged during rendering time.)
2017-04-21[MERGE] forward port branch saas-11 up to a0ff1f2ad84Christophe Simonis
2017-04-21[MERGE] forward port branch saas-6 up to b084ffd7f11Christophe Simonis
2017-04-20[FIX] web_enterprise: kanban_state_selection ieNicolas Lempereur
On IE (from 9.0 up to at least IE EDGE 14) we have this behavior for the method serializeToString of XMLSerializer: > (new XMLSerializer()).serializeToString($('<b>"</b>')[0]) '<b xmlns="http://www.w3.org/1999/xhtml">"</b>' > (new XMLSerializer()).serializeToString($('<b>"</b>')[0].firstChild) '&quot;' Whilst browser such as chromium or firefox have: > (new XMLSerializer()).serializeToString($('<b>"</b>')[0]) '<b xmlns="http://www.w3.org/1999/xhtml">"</b>' > (new XMLSerializer()).serializeToString($('<b>"</b>')[0].firstChild) '"' Hence for IE9 and over, if in a `<t t-extend/>` a `t-jquery` sub-directive (without `t-operation`) is available, we can have broken javascript if a " is transformed into an &quot; at a unfortunate location. This commit favour node.data over XMLSerializer serializeToString to avoid the possibility of this issue when a text node is processed. opw-727283
2017-03-06[FIX] web: IE <= 11.0 doesn't support ChildNode.removeDenis Ledoux
IE 11.0 doesn't support `Childnode.remove`: http://caniuse.com/#feat=childnode-remove As a workaround, we use `Node.removeChild`, which is more widely supported. opw-710617
2017-02-28[FIX] qweb2.js: fix erratic object type detection in foreach (Fixes #15655)Fabien Meghazi
Could not add a test as the qweb js testsuite is broken and it's xml test files have been modified in order to test qweb.py specific cases.
2016-09-09[ADD] web: Add extra condition branching (t-elif, t-else)Fabien Meghazi
A new preprocess method is added to the template engine in order to do preprocessing/sanitization of the templates before compilation. This method can be overloaded in order to add new features such as translation, ...
2016-01-26[FIX] web: change qweb to work around phantomjs bugGéry Debongnie
This commit does not actually fix qweb2.js, but it works around a phantomjs bug. The problem with phantomjs is that in some situations, the xmlhttprequests are dropped with a status 0. It is most likely related to the issue: https://github.com/ariya/phantomjs/issues/11195 In our testing framework, it seems to appear when requests sent before the 'load' event of phantomjs are received after, and also when those requests are listened with the onreadystatechange handler. The bug does not appear if we use addEventListener with the 'load' event (at least, not for a few builds) This commit does not worsen qweb, and it is also a small improvement in style (in my opinion).
2016-01-05[FIX] qweb2.js: improve debuggingRichard Mathot
2015-06-11[IMP] qweb2.js: display with console.debug the error message and the ↵Christophe Matthieu
template name when the qweb try to compute a wrong template
2015-01-30[IMP] qweb: Allow to propagate value to variables outside the loop.Jeremy Kersten
If the variable was existing outside the context of the ``foreach``, the value is copied at the end of the foreach into the global context. Fix #4461 - Q74531 - Q71486 - Q71675
2015-01-30[IMP] qweb: Allow to propagate value to variables outside the loop.Jeremy Kersten
If the variable was existing outside the context of the ``foreach``, the value is copied at the end of the foreach into the global context. Fix #4461 - Q74531 - Q71486 - Q71675
2014-10-16[ADD] QWeb2: add support for operation='attributes' in a t-extendFabien Meghazi
Same syntax as server's position='attributes' on view inheritance
2014-10-14[FIX] implementation of t-call's 0-index in qweb-jsXavier Morel
Had expected regularity, had not noticed the Python version is really an ignoble hack where the string "0" (exactly) is interpreted in a specific manner when used in t-raw and format strings, *and nowhere else*. Had special-cased the expression everywhere which broke e.g. <t-set="xxx" t-value="0"/>. Reproduce Python behavior more closely, and strongly consider swapping out both for something different e.g. [[content]] or something like that, which doesn't cause problems in Python but doesn't have to be so specially cased either.
2014-10-06[ADD] qweb: call directive's bodyXavier Morel
* __content__ can't be used in Python implementation because safe_eval, so use ``0`` from Python implementation instead * remove postfix from t-call tests because due to implementation details all whitespace crap following a t-name is added to rendered template in Python impl, and don't want to normalize whitespace.
2014-10-06[IMP] qweb doc, testsXavier Morel
* document qweb based (mostly) on JS version * convert JS qweb tests to (mostly) language-independent XML so they can be used for JS and Python implementations * add some more tests (e.g. precedence between t-value and body in t-set) * remove ``t-import`` * fix parity in foreach(dict) (and rename some variables to make array and object versions more similar)
2014-10-06[ADD] qweb-js: escf, rawf for parity with Python versionXavier Morel
2014-10-06[ADD] qweb-js: jinja-style interpolation patternXavier Morel
2014-10-06[IMP] qweb-js: reimplement string interpolation compilation as a single passXavier Morel
2014-10-06[IMP] update qweb-js testsXavier Morel
* latest qunit * template loading (handle async) * add format tests
2014-05-07[FIX] Do not self close empty elements that are not html void elementsFabien Meghazi
bzr revid: fme@openerp.com-20140507121413-o7jqhexbm1wmitt6
2014-01-15[REM] Removed useless QWeb t-escf and t-rawfFabien Meghazi
bzr revid: fme@openerp.com-20140115182018-d7q3e6elm6uqh0ox
2013-09-24[MERGE] upstreamFabien Meghazi
bzr revid: fme@openerp.com-20130814164422-l0h0ueue0fwk94uu bzr revid: chm@openerp.com-20130828165815-a901l9gx66lj0pj1 bzr revid: fme@openerp.com-20130924125103-65bngr3rnm6k7u3a
2013-08-19[REVERT] reverted 3812 because it's an incorrect way to upgrade an external ↵niv-openerp
dependency of OpenERP bzr revid: nicolas.vanhoren@openerp.com-20130819092940-9vqh5036p7rf2azv
2013-08-14[ADD] QWeb: add async api (backward compatible)Fabien Meghazi
bzr revid: fme@openerp.com-20130814164322-cny24d0i6tg4ftvn
2013-07-31Updated qwebniv-openerp
bzr revid: nicolas.vanhoren@openerp.com-20130731141139-7ssepci9vxnp9hpf
2012-12-06[FIX] QWeb: purge compiled template when template is addedFabien Meghazi
bzr revid: fme@openerp.com-20121206132115-6fyedomrrchrxc43
2012-11-21[FIX] qweb: <t t-log> action was generating invalid codeChristophe Simonis
bzr revid: chs@openerp.com-20121121155001-7gwb3w3mxqevxibm
2012-09-25[ADD] Add 'window' in QWeb reserved wordsFabien Meghazi
bzr revid: fme@openerp.com-20120925141558-zlj6f328oya3z5oy
2012-05-21[ADD] QWeb2: added 'void' reserved keywordFabien Meghazi
bzr revid: fme@openerp.com-20120521114038-tz48ac3cgg8zjmti
2012-02-13[FIX] QWeb2: Array-like character access in String is not supported in IE<8Fabien Meghazi
bzr revid: fme@openerp.com-20120213144234-dtdw5e8ho4x85frj
2012-02-07[IMP] Add QWeb preprocess_node callback. Translate @label, @title and @alt ↵Fabien Meghazi
attributes in web client bzr revid: fme@openerp.com-20120207132901-ifwnfj6c4mp451tl
2012-02-01[REM] QWeb: removed xpath supportFabien Meghazi
bzr revid: fme@openerp.com-20120201132217-h2i9a3g082i9ui9y
2012-02-01[FIX] Use childnodes and not the whole extend nodeFabien Meghazi
bzr revid: fme@openerp.com-20120201124822-xo1msj0ou09o73uh
2012-02-01[FIX] QWeb template inheritance done rightFabien Meghazi
bzr revid: fme@openerp.com-20120201122926-poh3q2157ra9tzjd
2012-01-25[IMP] avoid losing error message when DOM parser fails to initialize in MSIEXavier Morel
bzr revid: xmo@openerp.com-20120125160949-5pr4h7aquohykdn2
2012-01-18[FIX] Internet Explorer can't CDATA in HTML documents, convert XML CDATA ↵Xavier Morel
sections into TEXT html sections bzr revid: xmo@openerp.com-20120118112451-f7sbhzalhl2vapmc
2012-01-18[FIX] XML serialization for MSIE8 (not by much, but now it kinda works again)Xavier Morel
bzr revid: xmo@openerp.com-20120118105751-2jnwcilwc5p6kgth