예제 #1
0
파일: element.php 프로젝트: boltphp/core
 public function __construct($dom, $node = false)
 {
     $this->_dom = $dom;
     $this->_node = $node;
     $this->_guid = b::guid("domref");
     $this->attr('data-domref', $this->_guid);
 }
예제 #2
0
파일: dom.php 프로젝트: boltphp/core
 public function offsetSet($name, $value)
 {
     $el = $this->find($name)->first();
     if ($el->hasChildNodes()) {
         foreach ($el->childNodes as $child) {
             $child->parentNode->removeChild($child);
         }
     }
     if (stripos($value, '<') !== false and stripos($value, '>') !== false) {
         $guid = b::guid("_x_dom");
         $_ = new \DOMDocument();
         $_->loadHTML("<div id='{$guid}'>" . $value . "</div>");
         $children = $_->getElementById($guid)->childNodes;
         foreach ($children as $child) {
             $el->appendChild($this->_doc->importNode($child, true));
         }
     } else {
         $el->appendChild(new \DOMText($value));
     }
     return $this;
 }