mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] blockdom: properly merge dynamic class values
Class attributes are managed in a specific way in owl: they are merged with existing class attributes, and also, they can be defined in multiple ways (t-att-class, t-attf-class, t-att=['class', ...] and each of these can be combined together. Before this commit, the `t-att` syntax was handled as a normal attribute, and therefore, would not combine as required with existing classes. closes #1453
This commit is contained in:
committed by
Sam Degueldre
parent
59c49b5833
commit
23c7d19ef0
@@ -145,3 +145,34 @@ test("class attribute (with a preexisting value", async () => {
|
||||
patch(tree, block([""]));
|
||||
expect(fixture.innerHTML).toBe(`<div class="tomato"></div>`);
|
||||
});
|
||||
|
||||
test("block-class attributes with preexisting class attribute", async () => {
|
||||
const block = createBlock('<div block-attributes="0" class="owl"></div>');
|
||||
const tree = block([{ class: "eagle" }]);
|
||||
|
||||
mount(tree, fixture);
|
||||
expect(fixture.innerHTML).toBe(`<div class="owl eagle"></div>`);
|
||||
|
||||
patch(tree, block([{ class: "falcon" }]));
|
||||
expect(fixture.innerHTML).toBe(`<div class="owl falcon"></div>`);
|
||||
|
||||
patch(tree, block([{}]));
|
||||
expect(fixture.innerHTML).toBe(`<div class="owl"></div>`);
|
||||
});
|
||||
|
||||
test("block-class attributes (array syntax) with preexisting class attribute", async () => {
|
||||
const block = createBlock('<div block-attributes="0" class="owl"></div>');
|
||||
const tree = block([["class", "eagle"]]);
|
||||
|
||||
mount(tree, fixture);
|
||||
expect(fixture.innerHTML).toBe(`<div class="owl eagle"></div>`);
|
||||
|
||||
patch(tree, block([["class", "falcon"]]));
|
||||
expect(fixture.innerHTML).toBe(`<div class="owl falcon"></div>`);
|
||||
|
||||
patch(tree, block([["class", ""]]));
|
||||
expect(fixture.innerHTML).toBe(`<div class="owl"></div>`);
|
||||
|
||||
patch(tree, block([["class", "buzzard"]]));
|
||||
expect(fixture.innerHTML).toBe(`<div class="owl buzzard"></div>`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user