diff --git a/phpQuery/phpQuery/DOMDocumentWrapper.php b/phpQuery/phpQuery/DOMDocumentWrapper.php index 47ce35c..a58b1f3 100644 --- a/phpQuery/phpQuery/DOMDocumentWrapper.php +++ b/phpQuery/phpQuery/DOMDocumentWrapper.php @@ -59,6 +59,7 @@ public function load($markup, $contentType = null, $newDocumentID = null) { $this->root = $this->document; $this->charset = $this->document->encoding; // TODO isDocumentFragment + $loaded = true; } else { $loaded = $this->loadMarkup($markup); } @@ -677,4 +678,4 @@ public static function expandEmptyTag($tag, $xml){ } return $xml; } -} \ No newline at end of file +} diff --git a/phpQuery/phpQuery/phpQueryObject.php b/phpQuery/phpQuery/phpQueryObject.php index 9693cb9..db18fda 100644 --- a/phpQuery/phpQuery/phpQueryObject.php +++ b/phpQuery/phpQuery/phpQueryObject.php @@ -583,11 +583,12 @@ public function newInstance($newStack = null) { * @access private */ protected function matchClasses($class, $node) { + $nodeClasses = preg_split('/\s+/', $node->getAttribute('class') ); + // multi-class if ( mb_strpos($class, '.', 1)) { $classes = explode('.', substr($class, 1)); $classesCount = count( $classes ); - $nodeClasses = explode(' ', $node->getAttribute('class') ); $nodeClassesCount = count( $nodeClasses ); if ( $classesCount > $nodeClassesCount ) return false; @@ -604,8 +605,7 @@ protected function matchClasses($class, $node) { return in_array( // strip leading dot from class name substr($class, 1), - // get classes for element as array - explode(' ', $node->getAttribute('class') ) + $nodeClasses ); } } @@ -2264,6 +2264,20 @@ public function text($text = null, $callback1 = null, $callback2 = null, $callba } return $return; } + + /** + * @return The text content of each matching element, like + * text() but returns an array with one entry per matched element. + * Read only. + */ + public function texts($attr = null) { + $results = array(); + foreach($this->elements as $node) { + $results[] = $node->textContent; + } + return $results; + } + /** * Enter description here... * @@ -2631,6 +2645,22 @@ public function attr($attr = null, $value = null) { return is_null($value) ? '' : $this; } + + /** + * @return The same attribute of each matching element, like + * attr() but returns an array with one entry per matched element. + * Read only. + */ + public function attrs($attr = null) { + $results = array(); + foreach($this->stack(1) as $node) { + $results[] = $node->hasAttribute($attr) + ? $node->getAttribute($attr) + : null; + } + return $results; + } + /** * @access private */