Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/css-selector/XPath/Extension/HtmlExtension.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
| author | Chris Cannam |
|---|---|
| date | Mon, 23 Apr 2018 09:46:53 +0100 |
| parents | 4c8ae668cc8c |
| children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
| 13:5fb285c0d0e3 | 14:1fec387a4317 |
|---|---|
| 26 * | 26 * |
| 27 * @internal | 27 * @internal |
| 28 */ | 28 */ |
| 29 class HtmlExtension extends AbstractExtension | 29 class HtmlExtension extends AbstractExtension |
| 30 { | 30 { |
| 31 /** | |
| 32 * Constructor. | |
| 33 * | |
| 34 * @param Translator $translator | |
| 35 */ | |
| 36 public function __construct(Translator $translator) | 31 public function __construct(Translator $translator) |
| 37 { | 32 { |
| 38 $translator | 33 $translator |
| 39 ->getExtension('node') | 34 ->getExtension('node') |
| 40 ->setFlag(NodeExtension::ELEMENT_NAME_IN_LOWER_CASE, true) | 35 ->setFlag(NodeExtension::ELEMENT_NAME_IN_LOWER_CASE, true) |
| 67 'lang' => array($this, 'translateLang'), | 62 'lang' => array($this, 'translateLang'), |
| 68 ); | 63 ); |
| 69 } | 64 } |
| 70 | 65 |
| 71 /** | 66 /** |
| 72 * @param XPathExpr $xpath | |
| 73 * | |
| 74 * @return XPathExpr | 67 * @return XPathExpr |
| 75 */ | 68 */ |
| 76 public function translateChecked(XPathExpr $xpath) | 69 public function translateChecked(XPathExpr $xpath) |
| 77 { | 70 { |
| 78 return $xpath->addCondition( | 71 return $xpath->addCondition( |
| 81 ."and (@type = 'checkbox' or @type = 'radio'))" | 74 ."and (@type = 'checkbox' or @type = 'radio'))" |
| 82 ); | 75 ); |
| 83 } | 76 } |
| 84 | 77 |
| 85 /** | 78 /** |
| 86 * @param XPathExpr $xpath | |
| 87 * | |
| 88 * @return XPathExpr | 79 * @return XPathExpr |
| 89 */ | 80 */ |
| 90 public function translateLink(XPathExpr $xpath) | 81 public function translateLink(XPathExpr $xpath) |
| 91 { | 82 { |
| 92 return $xpath->addCondition("@href and (name(.) = 'a' or name(.) = 'link' or name(.) = 'area')"); | 83 return $xpath->addCondition("@href and (name(.) = 'a' or name(.) = 'link' or name(.) = 'area')"); |
| 93 } | 84 } |
| 94 | 85 |
| 95 /** | 86 /** |
| 96 * @param XPathExpr $xpath | |
| 97 * | |
| 98 * @return XPathExpr | 87 * @return XPathExpr |
| 99 */ | 88 */ |
| 100 public function translateDisabled(XPathExpr $xpath) | 89 public function translateDisabled(XPathExpr $xpath) |
| 101 { | 90 { |
| 102 return $xpath->addCondition( | 91 return $xpath->addCondition( |
| 122 ); | 111 ); |
| 123 // todo: in the second half, add "and is not a descendant of that fieldset element's first legend element child, if any." | 112 // todo: in the second half, add "and is not a descendant of that fieldset element's first legend element child, if any." |
| 124 } | 113 } |
| 125 | 114 |
| 126 /** | 115 /** |
| 127 * @param XPathExpr $xpath | |
| 128 * | |
| 129 * @return XPathExpr | 116 * @return XPathExpr |
| 130 */ | 117 */ |
| 131 public function translateEnabled(XPathExpr $xpath) | 118 public function translateEnabled(XPathExpr $xpath) |
| 132 { | 119 { |
| 133 return $xpath->addCondition( | 120 return $xpath->addCondition( |
| 160 .')' | 147 .')' |
| 161 ); | 148 ); |
| 162 } | 149 } |
| 163 | 150 |
| 164 /** | 151 /** |
| 165 * @param XPathExpr $xpath | |
| 166 * @param FunctionNode $function | |
| 167 * | |
| 168 * @return XPathExpr | 152 * @return XPathExpr |
| 169 * | 153 * |
| 170 * @throws ExpressionErrorException | 154 * @throws ExpressionErrorException |
| 171 */ | 155 */ |
| 172 public function translateLang(XPathExpr $xpath, FunctionNode $function) | 156 public function translateLang(XPathExpr $xpath, FunctionNode $function) |
| 189 Translator::getXpathLiteral(strtolower($arguments[0]->getValue()).'-') | 173 Translator::getXpathLiteral(strtolower($arguments[0]->getValue()).'-') |
| 190 )); | 174 )); |
| 191 } | 175 } |
| 192 | 176 |
| 193 /** | 177 /** |
| 194 * @param XPathExpr $xpath | |
| 195 * | |
| 196 * @return XPathExpr | 178 * @return XPathExpr |
| 197 */ | 179 */ |
| 198 public function translateSelected(XPathExpr $xpath) | 180 public function translateSelected(XPathExpr $xpath) |
| 199 { | 181 { |
| 200 return $xpath->addCondition("(@selected and name(.) = 'option')"); | 182 return $xpath->addCondition("(@selected and name(.) = 'option')"); |
| 201 } | 183 } |
| 202 | 184 |
| 203 /** | 185 /** |
| 204 * @param XPathExpr $xpath | |
| 205 * | |
| 206 * @return XPathExpr | 186 * @return XPathExpr |
| 207 */ | 187 */ |
| 208 public function translateInvalid(XPathExpr $xpath) | 188 public function translateInvalid(XPathExpr $xpath) |
| 209 { | 189 { |
| 210 return $xpath->addCondition('0'); | 190 return $xpath->addCondition('0'); |
| 211 } | 191 } |
| 212 | 192 |
| 213 /** | 193 /** |
| 214 * @param XPathExpr $xpath | |
| 215 * | |
| 216 * @return XPathExpr | 194 * @return XPathExpr |
| 217 */ | 195 */ |
| 218 public function translateHover(XPathExpr $xpath) | 196 public function translateHover(XPathExpr $xpath) |
| 219 { | 197 { |
| 220 return $xpath->addCondition('0'); | 198 return $xpath->addCondition('0'); |
| 221 } | 199 } |
| 222 | 200 |
| 223 /** | 201 /** |
| 224 * @param XPathExpr $xpath | |
| 225 * | |
| 226 * @return XPathExpr | 202 * @return XPathExpr |
| 227 */ | 203 */ |
| 228 public function translateVisited(XPathExpr $xpath) | 204 public function translateVisited(XPathExpr $xpath) |
| 229 { | 205 { |
| 230 return $xpath->addCondition('0'); | 206 return $xpath->addCondition('0'); |
