4 * Definition that uses different definitions depending on context.
6 * The del and ins tags are notable because they allow different types of
7 * elements depending on whether or not they're in a block or inline context.
8 * Chameleon allows this behavior to happen by using two different
9 * definitions depending on context. While this somewhat generalized,
10 * it is specifically intended for those two tags.
12 class HTMLPurifier_ChildDef_Chameleon
extends HTMLPurifier_ChildDef
16 * Instance of the definition object to use when inline. Usually stricter.
17 * @type HTMLPurifier_ChildDef_Optional
22 * Instance of the definition object to use when block.
23 * @type HTMLPurifier_ChildDef_Optional
30 public $type = 'chameleon';
33 * @param array $inline List of elements to allow when inline.
34 * @param array $block List of elements to allow when block.
36 public function __construct($inline, $block)
38 $this->inline
= new HTMLPurifier_ChildDef_Optional($inline);
39 $this->block
= new HTMLPurifier_ChildDef_Optional($block);
40 $this->elements
= $this->block
->elements
;
44 * @param HTMLPurifier_Node[] $children
45 * @param HTMLPurifier_Config $config
46 * @param HTMLPurifier_Context $context
49 public function validateChildren($children, $config, $context)
51 if ($context->get('IsInline') === false) {
52 return $this->block
->validateChildren(
58 return $this->inline
->validateChildren(