Support a class to be automatically added to transformed elements

This commit is contained in:
Jeremy Ruston
2026-01-23 22:26:51 +00:00
parent 9aaab87b87
commit b27d102d55
2 changed files with 7 additions and 2 deletions
+4
View File
@@ -46,6 +46,10 @@ ElementWidget.prototype.render = function(parent,nextSibling) {
var mappedTag = this.getVariable("tv-map-" + this.tag);
if(mappedTag) {
this.tag = mappedTag.trim();
var mappedClass = this.getVariable("tv-map-" + this.tag + "-class");
if(mappedClass) {
this.setAttribute("class",mappedClass.trim() + (this.getAttribute("class") ? " " + this.getAttribute("class") : ""));
}
}
// Select the namespace for the tag
var XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml",
@@ -7,12 +7,13 @@ title: Output
\whitespace trim
<!-- Map <p> to <div> -->
<!-- Map <p> to <div>, adding the class my-class -->
\define tv-map-p() div
\define tv-map-p-class() my-class
This is a paragraph
+
title: ExpectedResult
<div>This is a paragraph</div>
<div class="my-class">This is a paragraph</div>