Fix infinite loop involving wrapping formedness.
[htmlpurifier.git] / library / HTMLPurifier / AttrTransform / BoolToCSS.php
blob51159b67157de07846eb9f0b9af3486817ab5d69
1 <?php
3 /**
4 * Pre-transform that changes converts a boolean attribute to fixed CSS
5 */
6 class HTMLPurifier_AttrTransform_BoolToCSS extends HTMLPurifier_AttrTransform {
8 /**
9 * Name of boolean attribute that is trigger
11 protected $attr;
13 /**
14 * CSS declarations to add to style, needs trailing semicolon
16 protected $css;
18 /**
19 * @param $attr string attribute name to convert from
20 * @param $css string CSS declarations to add to style (needs semicolon)
22 public function __construct($attr, $css) {
23 $this->attr = $attr;
24 $this->css = $css;
27 public function transform($attr, $config, $context) {
28 if (!isset($attr[$this->attr])) return $attr;
29 unset($attr[$this->attr]);
30 $this->prependCSS($attr, $this->css);
31 return $attr;
36 // vim: et sw=4 sts=4