jQuery filter and html return strange result
<p>Why the following code not work as expected? (Select all elements before the div with class = clear?)</p>

<p><strong>HTML:</strong></p>

<pre><code>&lt;div id="text"&gt;    
    line0
    &lt;div&gt;line1&lt;/div&gt;
    &lt;div&gt;line2&lt;/div&gt;

    &lt;div class="clear" /&gt;        
    &lt;div&gt;dummy&lt;/div&gt;
    &lt;p&gt;dummy&lt;/p&gt;        
&lt;/div&gt;
</code></pre>

<p><strong>JS:</strong></p>

<pre><code>var allow = true;    
var output = $('#text *').filter(function(index) {        
    if( $(this).attr("class") == 'clear') {
        allow = false;
    }

    return allow;        
}).html().trim();

alert( output );
</code></pre>

<p><strong>​Output:</strong></p>

<pre><code>line1
</code></pre>

<p><strong>Expect:</strong>
    line0
    line1
    line2</p>
