@@ 16-54 (lines=39) @@ | ||
13 | * |
|
14 | * https://html.spec.whatwg.org/multipage/semantics.html#the-tbody-element |
|
15 | */ |
|
16 | class Tbody extends OpenElement |
|
17 | { |
|
18 | protected function doClean(LoggerInterface $logger) |
|
19 | { |
|
20 | if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) { |
|
21 | // "table" must be parent. |
|
22 | $parent = $this->getParent(); |
|
23 | if ($parent !== null && $parent->getName() != 'table') { |
|
24 | $logger->debug('Element "tbody" must be a child of the "table" element.'); |
|
25 | ||
26 | return false; |
|
27 | } |
|
28 | ||
29 | // Children can be "tr" and script supporting elements. |
|
30 | foreach ($this->children as $child) { |
|
31 | if ($child->getType() == Token::COMMENT) { |
|
32 | continue; |
|
33 | } |
|
34 | ||
35 | if ($child->getType() !== Token::ELEMENT) { |
|
36 | $logger->debug('Removing ' . $child . '. Only elements allowed as children of "tbody" element.'); |
|
37 | $this->removeChild($child); |
|
38 | ||
39 | continue; |
|
40 | } |
|
41 | ||
42 | if ($child->getName() == 'tr' || |
|
43 | $child instanceof ScriptSupporting) { |
|
44 | continue; |
|
45 | } |
|
46 | ||
47 | $logger->debug('Removing ' . $child . '. Only "tr" and script supporting elements allowed as children of "tbody" element.'); |
|
48 | $this->removeChild($child); |
|
49 | } |
|
50 | } |
|
51 | ||
52 | return true; |
|
53 | } |
|
54 | } |
|
55 |
@@ 16-54 (lines=39) @@ | ||
13 | * |
|
14 | * https://html.spec.whatwg.org/multipage/semantics.html#the-tfoot-element |
|
15 | */ |
|
16 | class Tfoot extends OpenElement |
|
17 | { |
|
18 | protected function doClean(LoggerInterface $logger) |
|
19 | { |
|
20 | if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) { |
|
21 | // "table" must be parent. |
|
22 | $parent = $this->getParent(); |
|
23 | if ($parent !== null && $parent->getName() != 'table') { |
|
24 | $logger->debug('Element "tfoot" must be a child of the "table" element.'); |
|
25 | ||
26 | return false; |
|
27 | } |
|
28 | ||
29 | // Children can be "tr" and script supporting elements. |
|
30 | foreach ($this->children as $child) { |
|
31 | if ($child->getType() == Token::COMMENT) { |
|
32 | continue; |
|
33 | } |
|
34 | ||
35 | if ($child->getType() !== Token::ELEMENT) { |
|
36 | $logger->debug('Removing ' . $child . '. Only elements allowed as children of "tfoot" element.'); |
|
37 | $this->removeChild($child); |
|
38 | ||
39 | continue; |
|
40 | } |
|
41 | ||
42 | if ($child->getName() == 'tr' || |
|
43 | $child instanceof ScriptSupporting) { |
|
44 | continue; |
|
45 | } |
|
46 | ||
47 | $logger->debug('Removing ' . $child . '. Only "tr" and script supporting elements allowed as children of "tfoot" element.'); |
|
48 | $this->removeChild($child); |
|
49 | } |
|
50 | } |
|
51 | ||
52 | return true; |
|
53 | } |
|
54 | } |
|
55 |
@@ 16-54 (lines=39) @@ | ||
13 | * |
|
14 | * https://html.spec.whatwg.org/multipage/semantics.html#the-thead-element |
|
15 | */ |
|
16 | class Thead extends OpenElement |
|
17 | { |
|
18 | protected function doClean(LoggerInterface $logger) |
|
19 | { |
|
20 | if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) { |
|
21 | // "table" must be parent. |
|
22 | $parent = $this->getParent(); |
|
23 | if ($parent !== null && $parent->getName() != 'table') { |
|
24 | $logger->debug('Element "thead" must be a child of the "table" element.'); |
|
25 | ||
26 | return false; |
|
27 | } |
|
28 | ||
29 | // Children can be "tr" and script supporting elements. |
|
30 | foreach ($this->children as $child) { |
|
31 | if ($child->getType() == Token::COMMENT) { |
|
32 | continue; |
|
33 | } |
|
34 | ||
35 | if ($child->getType() !== Token::ELEMENT) { |
|
36 | $logger->debug('Removing ' . $child . '. Only elements allowed as children of "thead" element.'); |
|
37 | $this->removeChild($child); |
|
38 | ||
39 | continue; |
|
40 | } |
|
41 | ||
42 | if ($child->getName() == 'tr' || |
|
43 | $child instanceof ScriptSupporting) { |
|
44 | continue; |
|
45 | } |
|
46 | ||
47 | $logger->debug('Removing ' . $child . '. Only "tr" and script supporting elements allowed as children of "thead" element.'); |
|
48 | $this->removeChild($child); |
|
49 | } |
|
50 | } |
|
51 | ||
52 | return true; |
|
53 | } |
|
54 | } |
|
55 |