|
12 | 12 | * @property string outerhtml |
13 | 13 | * @property string innerhtml |
14 | 14 | * @property string text |
| 15 | + * @property \PHPHtmlParser\Dom\Tag tag |
| 16 | + * @property InnerNode parent |
15 | 17 | */ |
16 | 18 | abstract class AbstractNode |
17 | 19 | { |
@@ -78,6 +80,9 @@ public function __get($key) |
78 | 80 | return $this->innerHtml(); |
79 | 81 | case 'text': |
80 | 82 | return $this->text(); |
| 83 | + case 'tag': |
| 84 | + return $this->getTag(); |
| 85 | + case 'parent': $this->getParent(); |
81 | 86 | } |
82 | 87 |
|
83 | 88 | return null; |
@@ -214,33 +219,6 @@ public function getAncestor($id) |
214 | 219 | return null; |
215 | 220 | } |
216 | 221 |
|
217 | | - /** |
218 | | - * Shortcut to return the first child. |
219 | | - * |
220 | | - * @return AbstractNode |
221 | | - * @uses $this->getChild() |
222 | | - */ |
223 | | - public function firstChild() |
224 | | - { |
225 | | - reset($this->children); |
226 | | - $key = key($this->children); |
227 | | - |
228 | | - return $this->getChild($key); |
229 | | - } |
230 | | - |
231 | | - /** |
232 | | - * Attempts to get the last child. |
233 | | - * |
234 | | - * @return AbstractNode |
235 | | - */ |
236 | | - public function lastChild() |
237 | | - { |
238 | | - end($this->children); |
239 | | - $key = key($this->children); |
240 | | - |
241 | | - return $this->getChild($key); |
242 | | - } |
243 | | - |
244 | 222 | /** |
245 | 223 | * Attempts to get the next sibling. |
246 | 224 | * |
@@ -329,6 +307,29 @@ public function setAttribute($key, $value) |
329 | 307 | return $this; |
330 | 308 | } |
331 | 309 |
|
| 310 | + /** |
| 311 | + * A wrapper method that simply calls the removeAttribute method |
| 312 | + * on the tag of this node. |
| 313 | + * |
| 314 | + * @param string $key |
| 315 | + * @return void |
| 316 | + */ |
| 317 | + public function removeAttribute($key) |
| 318 | + { |
| 319 | + $this->tag->removeAttribute($key); |
| 320 | + } |
| 321 | + |
| 322 | + /** |
| 323 | + * A wrapper method that simply calls the removeAllAttributes |
| 324 | + * method on the tag of this node. |
| 325 | + * |
| 326 | + * @return void |
| 327 | + */ |
| 328 | + public function removeAllAttributes() |
| 329 | + { |
| 330 | + $this->tag->removeAllAttributes(); |
| 331 | + } |
| 332 | + |
332 | 333 | /** |
333 | 334 | * Function to locate a specific ancestor tag in the path to the root. |
334 | 335 | * |
|
0 commit comments