Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 43 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| InSelectInTable | |
0.00% |
0 / 43 |
|
0.00% |
0 / 4 |
552 | |
0.00% |
0 / 1 |
| characters | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| startTag | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
110 | |||
| endTag | |
0.00% |
0 / 22 |
|
0.00% |
0 / 1 |
132 | |||
| endDocument | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | declare( strict_types = 1 ); |
| 3 | |
| 4 | namespace Wikimedia\RemexHtml\TreeBuilder; |
| 5 | |
| 6 | use Wikimedia\RemexHtml\Tokenizer\Attributes; |
| 7 | |
| 8 | /** |
| 9 | * The "in select in table" insertion mode |
| 10 | */ |
| 11 | class InSelectInTable extends InsertionMode { |
| 12 | /** @inheritDoc */ |
| 13 | public function characters( $text, $start, $length, $sourceStart, $sourceLength ) { |
| 14 | $this->dispatcher->inSelect->characters( |
| 15 | $text, $start, $length, $sourceStart, $sourceLength ); |
| 16 | } |
| 17 | |
| 18 | /** @inheritDoc */ |
| 19 | public function startTag( $name, Attributes $attrs, $selfClose, $sourceStart, $sourceLength ) { |
| 20 | $builder = $this->builder; |
| 21 | $dispatcher = $this->dispatcher; |
| 22 | |
| 23 | switch ( $name ) { |
| 24 | case 'caption': |
| 25 | case 'table': |
| 26 | case 'tbody': |
| 27 | case 'tfoot': |
| 28 | case 'thead': |
| 29 | case 'tr': |
| 30 | case 'td': |
| 31 | case 'th': |
| 32 | $builder->error( "unexpected <$name> in select in table, closing select", |
| 33 | $sourceStart ); |
| 34 | $builder->popAllUpToName( 'select', $sourceStart, 0 ); |
| 35 | $dispatcher->reset() |
| 36 | ->startTag( $name, $attrs, $selfClose, $sourceStart, $sourceLength ); |
| 37 | break; |
| 38 | |
| 39 | default: |
| 40 | $dispatcher->inSelect->startTag( |
| 41 | $name, $attrs, $selfClose, $sourceStart, $sourceLength ); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | /** @inheritDoc */ |
| 46 | public function endTag( $name, $sourceStart, $sourceLength ) { |
| 47 | $builder = $this->builder; |
| 48 | $stack = $builder->stack; |
| 49 | $dispatcher = $this->dispatcher; |
| 50 | |
| 51 | switch ( $name ) { |
| 52 | case 'caption': |
| 53 | case 'table': |
| 54 | case 'tbody': |
| 55 | case 'tfoot': |
| 56 | case 'thead': |
| 57 | case 'tr': |
| 58 | case 'td': |
| 59 | case 'th': |
| 60 | if ( !$stack->isInTableScope( $name ) ) { |
| 61 | $builder->error( "unexpected </$name> in select in table, ignoring", |
| 62 | $sourceStart ); |
| 63 | return; |
| 64 | } |
| 65 | $builder->error( "unexpected </$name> in select in table, closing select", |
| 66 | $sourceStart ); |
| 67 | $builder->popAllUpToName( 'select', $sourceStart, 0 ); |
| 68 | $dispatcher->reset() |
| 69 | ->endTag( $name, $sourceStart, $sourceLength ); |
| 70 | break; |
| 71 | |
| 72 | default: |
| 73 | $dispatcher->inSelect->endTag( $name, $sourceStart, $sourceLength ); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | /** @inheritDoc */ |
| 78 | public function endDocument( $pos ) { |
| 79 | $this->dispatcher->inSelect->endDocument( $pos ); |
| 80 | } |
| 81 | } |