Completed
Last Updated: 12 Dec 2023 09:01 by ADMIN
Gerke van den Akker
Created on: 03 Nov 2023 15:52
Category: Editor
Type: Bug Report
1
Editor closes <source> tags incorrectly

Bug report

The <source> tag in the Editor gets closed incorrectly. It's a void element, so it should either close itself or not have a closing tag at all. To quote MDN:

The element is a void element, which means that it not only has no content but also has no closing tag. That is, you never use "</source>" in your HTML.

--- <source>: The Media or Image Source element

Reproduction of the problem

Follow these steps:

  • Create an editor with "viewHtml" enabled in the toolbar, e.g.:
$("#editor").kendoEditor({ tools: ["viewHtml"] });
  • Click the </> button to open the "view HTML" modal;
  • Update the HTML with this snippet:
<picture>
    <source media="(min-width: 0px)" srcset="https://picsum.photos/id/0/300/200.webp" type="image/webp" />
    <source media="(min-width: 0px)" srcset="https://picsum.photos/id/0/300/200.png" type="image/png" />
    <source media="(min-width: 0px)" srcset="https://picsum.photos/id/0/300/200.jpg" type="image/jpg" />
    <img src="https://picsum.photos/id/0/300/200.jpg" width="300" height="200" />
</picture>
  • Click the "Update" button in the HTML modal;
  • Now click the </> button again to view the HTML, and you'll notice that all <source> tags now have a </source> closing tag added.

Current behavior

All the <source> get closing tags (</source>), which makes the HTML invalid as it's a void element. Above snippet would get turned into this (indented for readability):

<picture>
    <source media="(min-width: 0px)" srcset="https://picsum.photos/id/0/300/200.webp" type="image/webp"></source>
    <source media="(min-width: 0px)" srcset="https://picsum.photos/id/0/300/200.png" type="image/png"></source>
    <source media="(min-width: 0px)" srcset="https://picsum.photos/id/0/300/200.jpg" type="image/jpg"></source>
    <img src="https://picsum.photos/id/0/300/200.jpg" width="300" height="200" />
</picture>

Expected/desired behavior

The <source> should not get a closing tag, but should either close themselves, or not be closed at all.

Environment

  • Kendo UI version: 2023.2.829
  • jQuery version: 3.4.1
  • Browser: [all]
0 comments