mirror of
https://github.com/gtbu/Typesetter-5.3-p8.git
synced 2025-03-12 11:03:15 +01:00
dom wrapper update 3.01
This commit is contained in:
parent
3c15dbec00
commit
04398734c3
5 changed files with 47 additions and 5 deletions
|
@ -45,7 +45,7 @@ gp_defined('notify_deprecated', true); // Since 5.2
|
|||
//gp_defined('CMS_DOMAIN', 'http://gpeasy.loc');
|
||||
gp_defined('CMS_DOMAIN', 'https://github.com/gtbu');
|
||||
gp_defined('CMS_READABLE_DOMAIN', 'github.com/gtbu');
|
||||
gp_defined('CMS_NAME', 'Typesetter');
|
||||
gp_defined('CMS_NAME', 'Typesetter5');
|
||||
gp_defined('CMS_NAME_FULL', 'Typesetter5 CMS');
|
||||
gp_defined('addon_browse_path', CMS_DOMAIN . '/index.php');
|
||||
gp_defined('debug_path', CMS_DOMAIN . '/index.php/Debug');
|
||||
|
|
2
include/thirdparty/dom/NodeList.php
vendored
2
include/thirdparty/dom/NodeList.php
vendored
|
@ -30,7 +30,7 @@ class NodeList extends NodeCollection
|
|||
* @param Document $document
|
||||
* @param iterable $nodes
|
||||
*/
|
||||
public function __construct(Document $document = null, ?iterable $nodes = null) {
|
||||
public function __construct(?Document $document = null, ?iterable $nodes = null) {
|
||||
parent::__construct($nodes);
|
||||
|
||||
$this->document = $document;
|
||||
|
|
42
include/thirdparty/dom/README.md
vendored
42
include/thirdparty/dom/README.md
vendored
|
@ -500,9 +500,21 @@ $doc->find('div').removeClass('first');
|
|||
self substituteWith(string|NodeList|\DOMNode|callable $input)
|
||||
```
|
||||
|
||||
Replace each node in the current set with the contents provided.
|
||||
|
||||
##### Example
|
||||
|
||||
``` php
|
||||
$doc = (new Document())->html('<p><b>Hello</b> <b>World!</b></p>');
|
||||
$doc->find('b')->substituteWith(function($node) {
|
||||
return '<em>' . $node->text() . '</em>';
|
||||
});
|
||||
echo $doc->html();
|
||||
```
|
||||
|
||||
*Result:*
|
||||
``` html
|
||||
<p><em>Hello</em> <em>World!</em></p>
|
||||
```
|
||||
|
||||
---
|
||||
|
@ -513,9 +525,33 @@ self substituteWith(string|NodeList|\DOMNode|callable $input)
|
|||
string|self text([string|NodeList|\DOMNode|callable $input = null])
|
||||
```
|
||||
|
||||
##### Example
|
||||
Get the text contents of the current set.
|
||||
|
||||
##### Example (get)
|
||||
|
||||
``` php
|
||||
$doc = (new Document())->html('<div class="text">Hello World!</div>');
|
||||
echo $doc->find('.text')->text();
|
||||
```
|
||||
|
||||
*Result:*
|
||||
``` html
|
||||
Hello World!
|
||||
```
|
||||
|
||||
Set the text contents for current set.
|
||||
|
||||
##### Example (set)
|
||||
|
||||
``` php
|
||||
$doc = (new Document())->html('<div class="text"><string>The quick brown</strong> fox <em>jumps over the lazy dog</em></div>');
|
||||
$doc->find('.text')->text('Hello World!');
|
||||
echo $doc->html();
|
||||
```
|
||||
|
||||
*Result:*
|
||||
``` html
|
||||
<div class="text">Hello World!</div>
|
||||
```
|
||||
|
||||
---
|
||||
|
@ -1092,6 +1128,8 @@ $slicedNodes = $nodes->slice(1, 3);
|
|||
int count()
|
||||
```
|
||||
|
||||
Return number of nodes in the current set
|
||||
|
||||
##### Example
|
||||
|
||||
``` php
|
||||
|
@ -1108,6 +1146,8 @@ echo $nodes->count();
|
|||
self each(callable $function)
|
||||
```
|
||||
|
||||
Iterate through for each item in the existing set via callback
|
||||
|
||||
##### Example
|
||||
|
||||
``` php
|
||||
|
|
|
@ -184,7 +184,9 @@ trait ManipulationTrait
|
|||
public function substituteWith(string|NodeList|\DOMNode|callable $input): self {
|
||||
$this->manipulateNodesWithInput($input, function($node, $newNodes) {
|
||||
foreach ($newNodes as $newNode) {
|
||||
$node->parent()->replaceChild($newNode, $node);
|
||||
if ($node->parent()) {
|
||||
$node->parent()->replaceChild($newNode, $node);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -297,7 +297,7 @@ trait TraversalTrait
|
|||
*
|
||||
* @return NodeList
|
||||
*/
|
||||
public function parents(string $selector = null): NodeList {
|
||||
public function parents(?string $selector = null): NodeList {
|
||||
return $this->parentsUntil(null, $selector);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue