PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.20
Booking for Appointments and Events Calendar – Amelia v1.2.20
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / masterminds / html5 / src / HTML5 / Parser / TreeBuildingRules.php
ameliabooking / vendor / masterminds / html5 / src / HTML5 / Parser Last commit date
CharacterReference.php 1 year ago DOMTreeBuilder.php 1 year ago EventHandler.php 1 year ago FileInputStream.php 1 year ago InputStream.php 1 year ago ParseError.php 1 year ago README.md 1 year ago Scanner.php 1 year ago StringInputStream.php 1 year ago Tokenizer.php 1 year ago TreeBuildingRules.php 1 year ago UTF8Utils.php 1 year ago
TreeBuildingRules.php
128 lines
1 <?php
2
3 namespace Masterminds\HTML5\Parser;
4
5 /**
6 * Handles special-case rules for the DOM tree builder.
7 *
8 * Many tags have special rules that need to be accomodated on an
9 * individual basis. This class handles those rules.
10 *
11 * See section 8.1.2.4 of the spec.
12 *
13 * @todo - colgroup and col special behaviors
14 * - body and head special behaviors
15 */
16 class TreeBuildingRules
17 {
18 protected static $tags = array(
19 'li' => 1,
20 'dd' => 1,
21 'dt' => 1,
22 'rt' => 1,
23 'rp' => 1,
24 'tr' => 1,
25 'th' => 1,
26 'td' => 1,
27 'thead' => 1,
28 'tfoot' => 1,
29 'tbody' => 1,
30 'table' => 1,
31 'optgroup' => 1,
32 'option' => 1,
33 );
34
35 /**
36 * Returns true if the given tagname has special processing rules.
37 */
38 public function hasRules($tagname)
39 {
40 return isset(static::$tags[$tagname]);
41 }
42
43 /**
44 * Evaluate the rule for the current tag name.
45 *
46 * This may modify the existing DOM.
47 *
48 * @return \DOMElement The new Current DOM element.
49 */
50 public function evaluate($new, $current)
51 {
52 switch ($new->tagName) {
53 case 'li':
54 return $this->handleLI($new, $current);
55 case 'dt':
56 case 'dd':
57 return $this->handleDT($new, $current);
58 case 'rt':
59 case 'rp':
60 return $this->handleRT($new, $current);
61 case 'optgroup':
62 return $this->closeIfCurrentMatches($new, $current, array(
63 'optgroup',
64 ));
65 case 'option':
66 return $this->closeIfCurrentMatches($new, $current, array(
67 'option',
68 ));
69 case 'tr':
70 return $this->closeIfCurrentMatches($new, $current, array(
71 'tr',
72 ));
73 case 'td':
74 case 'th':
75 return $this->closeIfCurrentMatches($new, $current, array(
76 'th',
77 'td',
78 ));
79 case 'tbody':
80 case 'thead':
81 case 'tfoot':
82 case 'table': // Spec isn't explicit about this, but it's necessary.
83
84 return $this->closeIfCurrentMatches($new, $current, array(
85 'thead',
86 'tfoot',
87 'tbody',
88 ));
89 }
90
91 return $current;
92 }
93
94 protected function handleLI($ele, $current)
95 {
96 return $this->closeIfCurrentMatches($ele, $current, array(
97 'li',
98 ));
99 }
100
101 protected function handleDT($ele, $current)
102 {
103 return $this->closeIfCurrentMatches($ele, $current, array(
104 'dt',
105 'dd',
106 ));
107 }
108
109 protected function handleRT($ele, $current)
110 {
111 return $this->closeIfCurrentMatches($ele, $current, array(
112 'rt',
113 'rp',
114 ));
115 }
116
117 protected function closeIfCurrentMatches($ele, $current, $match)
118 {
119 if (in_array($current->tagName, $match, true)) {
120 $current->parentNode->appendChild($ele);
121 } else {
122 $current->appendChild($ele);
123 }
124
125 return $ele;
126 }
127 }
128