mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] qweb: fix overlapping multi-class in t-att-class
Previously, if two attributes in t-att-class shared some classes, their presence would be determined by the last attribute declared, instead of being present if any attribute containing it evaluates to true. This commit fixes that.
This commit is contained in:
committed by
Géry Debongnie
parent
9fe2da704e
commit
b242230e20
@@ -27,3 +27,31 @@ exports[`qweb t-att t-att-class with multiple classes 2`] = `
|
||||
return vn4;
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`qweb t-att t-att-class with multiple classes, some of which are duplicate 1`] = `
|
||||
"function anonymous(context, extra
|
||||
) {
|
||||
// Template name: \\"test\\"
|
||||
let utils = this.constructor.utils;
|
||||
let scope = Object.create(context);
|
||||
let h = this.h;
|
||||
let _1 = utils.toClassObj({'a b c':scope['value'],'a b d':!scope['value']});
|
||||
let c2 = [], p2 = {key:2,class:_1};
|
||||
let vn2 = h('div', p2, c2);
|
||||
return vn2;
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`qweb t-att t-att-class with multiple classes, some of which are duplicate 2`] = `
|
||||
"function anonymous(context, extra
|
||||
) {
|
||||
// Template name: \\"test\\"
|
||||
let utils = this.constructor.utils;
|
||||
let scope = Object.create(context);
|
||||
let h = this.h;
|
||||
let _3 = utils.toClassObj({'a b c':scope['value'],'a b d':!scope['value']});
|
||||
let c4 = [], p4 = {key:4,class:_3};
|
||||
let vn4 = h('div', p4, c4);
|
||||
return vn4;
|
||||
}"
|
||||
`;
|
||||
|
||||
@@ -24,4 +24,13 @@ describe("qweb t-att", () => {
|
||||
'<div class="a b c"></div>'
|
||||
);
|
||||
});
|
||||
|
||||
test("t-att-class with multiple classes, some of which are duplicate", () => {
|
||||
expect(render(`<div t-att-class="{'a b c': value, 'a b d': !value}" />`, { value: true })).toBe(
|
||||
'<div class="a b c"></div>'
|
||||
);
|
||||
expect(render(`<div t-att-class="{'a b c': value, 'a b d': !value}" />`, { value: false })).toBe(
|
||||
'<div class="a b d"></div>'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user