vovanmozg / phpquery

Automatically exported from code.google.com/p/phpquery
0 stars 0 forks source link

text method can take an optional text string #46

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. add a tag with class="someclass"
2. pq(".someclass")->text("something<not a tag>");

What is the expected output? What do you see instead?
All the someclass should be filled with text "Something<not a tag>".
Original content of someclass is kept

What version of the product are you using? On what operating system?
9.4rc1 Linux

Please provide any additional information below.
Here is a quick fix I added.  Haven't thoroughly tested.
Replace text function with following.

    public function text($text = null) {
        if($text == null) {
            $return = '';
            foreach( $this->elements as $node ) {
                $return .= $node->textContent;
            }
            return $return;
        } else {
            return($this->html(htmlentities($text)));
        }
    } 

Original issue reported on code.google.com by aashe...@gmail.com on 1 Oct 2008 at 5:29

GoogleCodeExporter commented 8 years ago
I've maked a correct path in the first version of phpQuery I used but can't 
find it :/.
I expect that Tobiaz haven't any difficulties to resolve it ^^.

Original comment by nicolas....@gmail.com on 2 Oct 2008 at 7:56

GoogleCodeExporter commented 8 years ago
Fixed in r168 (branches/dev).

Sorry if i lost a patch before.

Original comment by tobiasz....@gmail.com on 2 Oct 2008 at 9:03