[FIX] web_editor: carry attributes of all tag other than LI
Commit [1] changed the behavior of `setTagName` to only carry the attributes of paragraph related elements. Ideally, this should not carry the attributes of `<li>` element only. [1]: fcb3846 task-3764154 closes odoo/odoo#155448 X-original-commit: 0a47626dba4019fabaf4e399db3369b3db2e712e Signed-off-by: Antoine Guenet (age) <age@odoo.com> Signed-off-by: Deependra Solanki (deso) <deso@odoo.com>
This commit is contained in:
@@ -2132,7 +2132,7 @@ export function setTagName(el, newTagName) {
|
||||
return el;
|
||||
}
|
||||
const n = document.createElement(newTagName);
|
||||
if (paragraphRelatedElements.includes(el.nodeName)) {
|
||||
if (el.nodeName !== 'LI') {
|
||||
const attributes = el.attributes;
|
||||
for (const attr of attributes) {
|
||||
n.setAttribute(attr.name, attr.value);
|
||||
|
||||
@@ -38,6 +38,20 @@ describe('List', () => {
|
||||
contentAfter: '<ul><li>ab[]cd</li></ul>',
|
||||
});
|
||||
});
|
||||
it('should turn a ordered list into a unordered list', async () => {
|
||||
await testEditor(BasicEditor, {
|
||||
contentBefore: '<ol><li>ab[]cd</li></ol>',
|
||||
stepFunction: toggleUnorderedList,
|
||||
contentAfter: '<ul><li>ab[]cd</li></ul>',
|
||||
});
|
||||
});
|
||||
it('should turn a checked list into a unordered list', async () => {
|
||||
await testEditor(BasicEditor, {
|
||||
contentBefore: '<ul class="o_checklist"><li>ab[]cd</li></ul>',
|
||||
stepFunction: toggleUnorderedList,
|
||||
contentAfter: '<ul><li>ab[]cd</li></ul>',
|
||||
});
|
||||
});
|
||||
it('should turn a heading into a list', async () => {
|
||||
await testEditor(BasicEditor, {
|
||||
contentBefore: '<h1>ab[]cd</h1>',
|
||||
@@ -307,6 +321,20 @@ describe('List', () => {
|
||||
contentAfter: '<ol><li>ab[]cd</li></ol>',
|
||||
});
|
||||
});
|
||||
it('should turn a unordered list into a ordered list', async () => {
|
||||
await testEditor(BasicEditor, {
|
||||
contentBefore: '<ul><li>ab[]cd</li></ul>',
|
||||
stepFunction: toggleOrderedList,
|
||||
contentAfter: '<ol><li>ab[]cd</li></ol>',
|
||||
});
|
||||
});
|
||||
it('should turn a checked list into a ordered list', async () => {
|
||||
await testEditor(BasicEditor, {
|
||||
contentBefore: '<ul class="o_checklist"><li>ab[]cd</li></ul>',
|
||||
stepFunction: toggleOrderedList,
|
||||
contentAfter: '<ol><li>ab[]cd</li></ol>',
|
||||
});
|
||||
});
|
||||
it('should turn a heading into a list', async () => {
|
||||
await testEditor(BasicEditor, {
|
||||
contentBefore: '<h1>ab[]cd</h1>',
|
||||
@@ -525,6 +553,22 @@ describe('List', () => {
|
||||
contentAfter: '<ul class="o_checklist"><li>ab[]cd</li></ul>',
|
||||
});
|
||||
});
|
||||
it('should turn a ordered list into a checklist', async () => {
|
||||
await testEditor(BasicEditor, {
|
||||
removeCheckIds: true,
|
||||
contentBefore: '<ol><li>ab[]cd</li></ol>',
|
||||
stepFunction: toggleCheckList,
|
||||
contentAfter: '<ul class="o_checklist"><li>ab[]cd</li></ul>',
|
||||
});
|
||||
});
|
||||
it('should turn a unordered list into a checklist', async () => {
|
||||
await testEditor(BasicEditor, {
|
||||
removeCheckIds: true,
|
||||
contentBefore: '<ul><li>ab[]cd</li></ul>',
|
||||
stepFunction: toggleCheckList,
|
||||
contentAfter: '<ul class="o_checklist"><li>ab[]cd</li></ul>',
|
||||
});
|
||||
});
|
||||
it('should turn a heading into a checklist', async () => {
|
||||
await testEditor(BasicEditor, {
|
||||
removeCheckIds: true,
|
||||
|
||||
Reference in New Issue
Block a user