1

Topic: htmLawed stripping web component elements

Hello all. I'm running into an issue where htmLawed is stripping out the <rh-table> elements we are attempting to wrap around tables (via CKEditor in D9). I've looked into the documentation and tried to add <rh-table> to the list of allowed elements via htmLawed's config. However, it seems that it won't allow new elements that aren't included in its default 118 elements.

Is it possible to get htmLawed to allow <rh-table>?

Thanks!

2

Re: htmLawed stripping web component elements

There is a way to allow non-standard HTML tags/elements to get through the htmLawed filter. See the second half of this section of the docs. Basically, you use $config['elements'] => '* + rhtable' and set $config['balance'] to 0.

This method has a drawback that tag balancing & nesting check has to be turned off (see docs).

Another drawback, which is seen with rh-table is that the non-standard element's name cannot have a hyphen character.

htmLawed doesn't support custom elements, which now are a part of the WHATWG HTML standard (Web Components). I will have to modify and issue a new release to add support for such elements. That should take care of your issue. Hopefully, I will be able to release within a few days.

In the meantime, you can consider this suggestion.

3

Re: htmLawed stripping web component elements

Thanks for the information! Very helpful.

4

Re: htmLawed stripping web component elements

The new version of htmLawed, 1.2.7 of 10 April 2022, fixes this issue.