From 379779363e5551ff2449dec54f887f2f60dc1074 Mon Sep 17 00:00:00 2001 From: Lucas Souza Date: Fri, 20 Jan 2012 16:50:54 -0200 Subject: [PATCH] Add acceptance for escape char in id selectors --- phpQuery/phpQuery/phpQueryObject.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/phpQuery/phpQuery/phpQueryObject.php b/phpQuery/phpQuery/phpQueryObject.php index 9693cb9..f2ec9d7 100644 --- a/phpQuery/phpQuery/phpQueryObject.php +++ b/phpQuery/phpQuery/phpQueryObject.php @@ -349,9 +349,12 @@ protected function parseSelector($query) { // IDs } else if ( $c == '#') { $i++; - while( isset($query[$i]) && ($this->isChar($query[$i]) || $query[$i] == '-')) { - $tmp .= $query[$i]; - $i++; + while( isset($query[$i]) && ($this->isChar($query[$i]) || $query[$i] == '-') || $query[$i] == '\\' || $query[$i-1] == '\\')) { + // Do not include escape char + if ($query[$i] == '\\'){ + $tmp .= $query[$i]; + $i++; + } } $return[] = '#'.$tmp; // SPECIAL CHARS @@ -1742,7 +1745,7 @@ public function replaceAll($selector) { public function remove($selector = null) { $loop = $selector ? $this->filter($selector)->elements - : $this->elements; + : $this->elements ?: phpQuery::pq($selector, $this->getDocumentID()); foreach($loop as $node) { if (! $node->parentNode ) continue;