odoo/openerp/addons
Xavier Morel 9cefa76988 [ADD] hasclass() xpath function
Server-side, view extension is done via xpath. This includes "template" views
full of HTML.

HTML elements often have a bunch of classes, sometimes even semantic
(!). XPath is generally great, but specifically lousy at dealing with
space-separated values: in standard XPath 1.0 to know if an element has a
class 'foo' the predicate is:

    contains(concat(' ', normalize-space(@class), ' '), ' foo ')

and this has to be fully duplicated if there's a second class involved.

Things are slightly better with EXSLT/XPath 2.0 and tokenize, but still not
great:

    tokenize(@class, '\s+') = 'foo'

and the equality check is very weird when unaware of XPath's evaluation rules.

``hasclass`` makes this much simpler to deal with: to get any ``foo`` node
with the class ``bar`` is as simple as:

    //foo[hasclass('bar')

and it can take multiple class, as with e.g. jquery it will return elements
with all specified classes.

Beware though, the predicate function will be called once for each element to
check, since it's implemented in pure python and not profiled elements should
be filtered as much as possible before this point.
2014-05-19 08:32:23 +02:00
..
base [ADD] hasclass() xpath function 2014-05-19 08:32:23 +02:00
test_convert move tests 2014-02-09 01:37:45 +01:00
test_converter [FIX] test_converter: force inherit_branding by passing the right context 2014-03-17 18:07:06 +01:00
test_exceptions move tests 2014-02-09 01:37:45 +01:00
test_impex [MERGE] forward port of branch saas-3 up to revid 5093 chs@openerp.com-20140318114540-l50kmo4azb57g31x 2014-03-18 13:41:12 +01:00
test_limits move tests 2014-02-09 01:37:45 +01:00
test_uninstall move tests 2014-02-09 01:37:45 +01:00
test_workflow move tests 2014-02-09 01:37:45 +01:00
__init__.py move tests 2014-02-09 01:37:45 +01:00