-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: allow binding directly to
data-element
- Loading branch information
Showing
5 changed files
with
60 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,23 +160,29 @@ public function bindListCallback( | |
|
||
public function cleanupDocument():void { | ||
$xpathResult = $this->document->evaluate( | ||
"//*/@*[starts-with(name(), 'data-bind')] | //*/@*[starts-with(name(), 'data-list')] | //*/@*[starts-with(name(), 'data-template')] | //*/@*[starts-with(name(), 'data-table-key')]" | ||
"//*/@*[starts-with(name(), 'data-bind')] | //*/@*[starts-with(name(), 'data-list')] | //*/@*[starts-with(name(), 'data-template')] | //*/@*[starts-with(name(), 'data-table-key')] | //*/@*[starts-with(name(), 'data-element')]" | ||
); | ||
|
||
$elementsToRemove = []; | ||
/** @var Attr $item */ | ||
foreach($xpathResult as $item) { | ||
Check failure on line 168 in src/DocumentBinder.php GitHub Actions / phpstan
|
||
if($item->ownerElement->hasAttribute("data-element")) { | ||
array_push($elementsToRemove, $item->ownerElement); | ||
$ownerElement = $item->ownerElement; | ||
if($ownerElement->hasAttribute("data-element")) { | ||
if(!$ownerElement->hasAttribute("data-bound")) { | ||
array_push($elementsToRemove, $ownerElement); | ||
} | ||
continue; | ||
} | ||
|
||
$item->ownerElement->removeAttribute($item->name); | ||
$ownerElement->removeAttribute($item->name); | ||
} | ||
|
||
foreach($this->document->querySelectorAll("[data-element]") as $dataElement) { | ||
$dataElement->removeAttribute("data-element"); | ||
} | ||
foreach($this->document->querySelectorAll("[data-bound]") as $dataBound) { | ||
$dataBound->removeAttribute("data-bound"); | ||
} | ||
|
||
foreach($elementsToRemove as $element) { | ||
$element->remove(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters