Skip to content
Snippets Groups Projects
Unverified Commit 6fa7700f authored by Hakim El Hattab's avatar Hakim El Hattab Committed by GitHub
Browse files

Merge pull request #2515 from Bagira80/boolean-attributes-from-markdown

Markdown: Boolean (data-)attributes will now be added to elements, too.
parents ff2a4192 f6d96fe4
No related branches found
No related tags found
No related merge requests found
......@@ -307,7 +307,7 @@
function addAttributeInElement( node, elementTarget, separator ) {
var mardownClassesInElementsRegex = new RegExp( separator, 'mg' );
var mardownClassRegex = new RegExp( "([^\"= ]+?)=\"([^\"=]+?)\"", 'mg' );
var mardownClassRegex = new RegExp( "([^\"= ]+?)=\"([^\"]+?)\"|(data-[^\"= ]+?)(?=[\" ])", 'mg' );
var nodeValue = node.nodeValue;
if( matches = mardownClassesInElementsRegex.exec( nodeValue ) ) {
......@@ -315,7 +315,11 @@
nodeValue = nodeValue.substring( 0, matches.index ) + nodeValue.substring( mardownClassesInElementsRegex.lastIndex );
node.nodeValue = nodeValue;
while( matchesClass = mardownClassRegex.exec( classes ) ) {
elementTarget.setAttribute( matchesClass[1], matchesClass[2] );
if( matchesClass[2] ) {
elementTarget.setAttribute( matchesClass[1], matchesClass[2] );
} else {
elementTarget.setAttribute( matchesClass[3], "" );
}
}
return true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment