-
-
Notifications
You must be signed in to change notification settings - Fork 25
Live properties
One of the underlying principals of the DOM is that properties of Nodes can be "live", meaning that their values change as the DOM changes. In PHP, this can only be implemented by using getters - otherwise known as Magic Methods.
Any class within this project that implements a getter or setter should use the LiveProperty
trait. This is due to the fact that things become unpredictable or confusing if an object uses a trait or extends a class that already has a __get
method.
As an example of how live properties are used, let's look at the ParentNode
trait. On line 25, we can see the getter for the children
property, called prop_get_children
. To show this live property in action, look at the next method in the same trait, firstElementChild
. The firstElementChild
method calls the trait's own live property directly as $this->children
.
PHP.Gt/Dom is a separately maintained component of PHP.Gt/WebEngine.