Correctly format logical tag attributes using the tinymce editor plugin

I am creating a tinymce editor plugin that adds some microdata to the selected text and I want to make sure that the final markup will be valid. as specified in the draft microdata specification, a new item is indicated by adding the itemscope attribute to the item, for example:

 <section itemscope itemtype="http://example.com/vocab/someobject" itemid="someid" > <meta itemprop="topic" content="something very interesting" /> .... other microdata stuff </section> 

I have extended tinymce configuration options for recognizing these microdata attributes:

 tinyMCE.init({ ... schema: "html5", extended_valid_elements:"@[itemscope|itemtype|itemid|itemprop|content],div,span,time[datetime]" ... }); 

and everything works. however, when I use the plugin, tiny mce still "fixes" my markup by adding a null value to the itemscope attribute, for example: itemscope="" . but the itemscope attribute is a boolean element, which AFAIU means it should not matter.

so the question is: a) is it still valid markup if the itemscope attribute matters? and b) if not, (how), can I configure tinymce to leave itemscope as the correct boolean attribute and not add the bit ="" ?

thanks!

+6
source share
1 answer

The value of the logical attribute must be an empty string or the name of the attribute itself . So, <div itemscope> , <div itemscope=""> and <div itemscope="itemscope"> equivalent.

+7
source

Source: https://habr.com/ru/post/913285/


All Articles