Update Composer packages
This commit is contained in:
parent
0320235f6c
commit
a8b68fb61b
378 changed files with 28466 additions and 28852 deletions
|
@ -21,20 +21,9 @@ use Kirby\Toolkit\Str;
|
|||
*/
|
||||
class Element
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $marks;
|
||||
protected array $marks;
|
||||
protected DOMElement $node;
|
||||
|
||||
/**
|
||||
* @var \DOMElement
|
||||
*/
|
||||
protected $node;
|
||||
|
||||
/**
|
||||
* @param \DOMElement $node
|
||||
* @param array $marks
|
||||
*/
|
||||
public function __construct(DOMElement $node, array $marks = [])
|
||||
{
|
||||
$this->marks = $marks;
|
||||
|
@ -44,12 +33,8 @@ class Element
|
|||
/**
|
||||
* The returns the attribute value or
|
||||
* the given fallback if the attribute does not exist
|
||||
*
|
||||
* @param string $attr
|
||||
* @param string|null $fallback
|
||||
* @return string|null
|
||||
*/
|
||||
public function attr(string $attr, string $fallback = null): ?string
|
||||
public function attr(string $attr, string|null $fallback = null): string|null
|
||||
{
|
||||
if ($this->node->hasAttribute($attr)) {
|
||||
return $this->node->getAttribute($attr) ?? $fallback;
|
||||
|
@ -60,8 +45,6 @@ class Element
|
|||
|
||||
/**
|
||||
* Returns a list of all child elements
|
||||
*
|
||||
* @return \DOMNodeList
|
||||
*/
|
||||
public function children(): DOMNodeList
|
||||
{
|
||||
|
@ -70,8 +53,6 @@ class Element
|
|||
|
||||
/**
|
||||
* Returns an array with all class names
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function classList(): array
|
||||
{
|
||||
|
@ -80,20 +61,16 @@ class Element
|
|||
|
||||
/**
|
||||
* Returns the value of the class attribute
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function className(): ?string
|
||||
public function className(): string|null
|
||||
{
|
||||
return $this->attr('class');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the original dom element
|
||||
*
|
||||
* @return \DOMElement
|
||||
*/
|
||||
public function element()
|
||||
public function element(): DOMElement
|
||||
{
|
||||
return $this->node;
|
||||
}
|
||||
|
@ -101,9 +78,6 @@ class Element
|
|||
/**
|
||||
* Returns an array with all nested elements
|
||||
* that could be found for the given query
|
||||
*
|
||||
* @param string $query
|
||||
* @return array
|
||||
*/
|
||||
public function filter(string $query): array
|
||||
{
|
||||
|
@ -121,11 +95,8 @@ class Element
|
|||
/**
|
||||
* Tries to find a single nested element by
|
||||
* query and otherwise returns null
|
||||
*
|
||||
* @param string $query
|
||||
* @return \Kirby\Parsley\Element|null
|
||||
*/
|
||||
public function find(string $query)
|
||||
public function find(string $query): Element|null
|
||||
{
|
||||
if ($result = $this->query($query)[0]) {
|
||||
return new static($result);
|
||||
|
@ -136,19 +107,14 @@ class Element
|
|||
|
||||
/**
|
||||
* Returns the inner HTML of the element
|
||||
*
|
||||
* @param array|null $marks List of allowed marks
|
||||
* @return string
|
||||
*/
|
||||
public function innerHtml(array $marks = null): string
|
||||
public function innerHtml(array|null $marks = null): string
|
||||
{
|
||||
return (new Inline($this->node, $marks ?? $this->marks))->innerHtml();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contents as plain text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function innerText(): string
|
||||
{
|
||||
|
@ -157,40 +123,31 @@ class Element
|
|||
|
||||
/**
|
||||
* Returns the full HTML for the element
|
||||
*
|
||||
* @param array|null $marks
|
||||
* @return string
|
||||
*/
|
||||
public function outerHtml(array $marks = null): string
|
||||
public function outerHtml(array|null $marks = null): string
|
||||
{
|
||||
return $this->node->ownerDocument->saveHtml($this->node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches nested elements
|
||||
*
|
||||
* @param string $query
|
||||
* @return DOMNodeList|null
|
||||
*/
|
||||
public function query(string $query)
|
||||
public function query(string $query): DOMNodeList|null
|
||||
{
|
||||
return (new DOMXPath($this->node->ownerDocument))->query($query, $this->node);
|
||||
$path = new DOMXPath($this->node->ownerDocument);
|
||||
return $path->query($query, $this->node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the element from the DOM
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function remove()
|
||||
public function remove(): void
|
||||
{
|
||||
$this->node->parentNode->removeChild($this->node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function tagName(): string
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue