| @@ 15-48 (lines=34) @@ | ||
| 12 | * |
|
| 13 | * https://html.spec.whatwg.org/multipage/semantics.html#the-source-element |
|
| 14 | */ |
|
| 15 | class Source extends ClosedElement |
|
| 16 | { |
|
| 17 | protected function getAllowedAttributes() |
|
| 18 | { |
|
| 19 | $sourceAllowedAttributes = array( |
|
| 20 | '/^src$/i' => Attribute::URI, |
|
| 21 | '/^type$/i' => Attribute::CS_STRING, |
|
| 22 | '/^srcset$/i' => Attribute::CS_STRING, |
|
| 23 | '/^sizes$/i' => Attribute::CS_STRING, |
|
| 24 | '/^media$/i' => Attribute::CS_STRING |
|
| 25 | ); |
|
| 26 | ||
| 27 | return array_merge( |
|
| 28 | $sourceAllowedAttributes, |
|
| 29 | parent::getAllowedAttributes() |
|
| 30 | ); |
|
| 31 | } |
|
| 32 | ||
| 33 | protected function removeInvalidSelf(LoggerInterface $logger) |
|
| 34 | { |
|
| 35 | // Child of "picture" element. |
|
| 36 | // Child of media element. |
|
| 37 | $parent = $this->getParent(); |
|
| 38 | if ($parent !== null && |
|
| 39 | !$parent instanceof Picture && |
|
| 40 | !$parent instanceof MediaElement) { |
|
| 41 | $logger->debug('Removing ' . $this . ' must be a child of "picture" element or a media element.'); |
|
| 42 | ||
| 43 | return true; |
|
| 44 | } |
|
| 45 | ||
| 46 | return false; |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||
| @@ 15-45 (lines=31) @@ | ||
| 12 | * |
|
| 13 | * https://html.spec.whatwg.org/multipage/semantics.html#the-th-element |
|
| 14 | */ |
|
| 15 | class Th extends OpenElement |
|
| 16 | { |
|
| 17 | protected function getAllowedAttributes() |
|
| 18 | { |
|
| 19 | $thAllowedAttributes = array( |
|
| 20 | '/^colspan$/i' => Attribute::INT, |
|
| 21 | '/^rowspan$/i' => Attribute::INT, |
|
| 22 | '/^headers$/i' => Attribute::CS_STRING, |
|
| 23 | '/^scope$/i' => Attribute::CS_STRING, |
|
| 24 | '/^abbr$/i' => Attribute::CS_STRING |
|
| 25 | ); |
|
| 26 | ||
| 27 | return array_merge( |
|
| 28 | $thAllowedAttributes, |
|
| 29 | parent::getAllowedAttributes() |
|
| 30 | ); |
|
| 31 | } |
|
| 32 | ||
| 33 | protected function removeInvalidSelf(LoggerInterface $logger) |
|
| 34 | { |
|
| 35 | // "tr" must be parent. |
|
| 36 | $parent = $this->getParent(); |
|
| 37 | if ($parent !== null && !$parent instanceof Tr) { |
|
| 38 | $logger->debug('Removing ' . $this . '. Must be a child of "tr" element.'); |
|
| 39 | ||
| 40 | return true; |
|
| 41 | } |
|
| 42 | ||
| 43 | return false; |
|
| 44 | } |
|
| 45 | } |
|
| 46 | ||
| @@ 14-46 (lines=33) @@ | ||
| 11 | * |
|
| 12 | * https://html.spec.whatwg.org/multipage/semantics.html#the-track-element |
|
| 13 | */ |
|
| 14 | class Track extends ClosedElement |
|
| 15 | { |
|
| 16 | protected function getAllowedAttributes() |
|
| 17 | { |
|
| 18 | $trackAllowedAttributes = array( |
|
| 19 | '/^kind$/i' => Attribute::CS_STRING, |
|
| 20 | '/^src$/i' => Attribute::URI, |
|
| 21 | '/^srclang$/i' => Attribute::CS_STRING, |
|
| 22 | '/^label$/i' => Attribute::CS_STRING, |
|
| 23 | '/^default$/i' => Attribute::BOOL |
|
| 24 | ); |
|
| 25 | ||
| 26 | return array_merge( |
|
| 27 | $trackAllowedAttributes, |
|
| 28 | parent::getAllowedAttributes() |
|
| 29 | ); |
|
| 30 | } |
|
| 31 | ||
| 32 | protected function removeInvalidSelf(LoggerInterface $logger) |
|
| 33 | { |
|
| 34 | // Must be child of "object" element. |
|
| 35 | $parent = $this->getParent(); |
|
| 36 | if ($parent !== null && |
|
| 37 | !$parent instanceof Video && |
|
| 38 | !$parent instanceof Audio) { |
|
| 39 | $logger->debug('Removing ' . $this . '. Must be a child of "video" or "audio" element.'); |
|
| 40 | ||
| 41 | return true; |
|
| 42 | } |
|
| 43 | ||
| 44 | return false; |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||