Correctly format boolean tag attributes with tinymce editor plugin

microdata, tinymce

Solution

The value of a boolean attribute must either be the empty string, or the name of the attribute itself. So, `<div itemscope>`, `<div itemscope="">`, and `<div itemscope="itemscope">` are all equivalent.

Problem

i am building a plugin for tinymce editor which adds some microdata to selected text, and i want to make sure the final markup will be valid. as specified by the draft microdata spec, a new item is indicated by adding the attribute `itemscope` to an element, 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 the configuration parameters of tinymce to recognize these microdata attributes: ``` tinyMCE.init({ ... schema: "html5", extended_valid_elements:"@[itemscope|itemtype|itemid|itemprop|content],div,span,time[datetime]" ... }); ``` and things are generally working. however, when i use the plugin, tiny mce is still "correcting" my markup by adding an empty value to the itemscope attribute, like so: `itemscope=""`. but the itemscope attribute is a boolean element, which AFAIU means that it should have no value. so the question is, a) is it still valid markup if the itemscope attribute has a value? and b) if not, (how) can i configure tinymce to leave itemscope as a proper boolean attribute, and not append the `=""` bit? thanks!

Original source