$endTagSet = $thorough ?
BalanceSets::$thoroughImpliedEndTagsSet :
BalanceSets::$impliedEndTagsSet;
- while ( $this->length() > 0 ) {
+ while ( $this->currentNode ) {
if ( $butnot !== null && $this->currentNode->isHtmlNamed( $butnot ) ) {
break;
}
* Return the adjusted current node.
*/
public function adjustedCurrentNode( $fragmentContext ) {
- return ( $fragmentContext && $this->length() === 1 ) ?
+ return ( $fragmentContext && count( $this->elements ) === 1 ) ?
$fragmentContext : $this->currentNode;
}
* @param int $idx
*/
public function popTo( $idx ) {
- while ( $this->length() > $idx ) {
+ $length = count( $this->elements );
+ for ( $length = count( $this->elements ); $length > $idx; $length-- ) {
$this->pop();
}
}
* @param BalanceElement|array|string $tag
*/
public function popTag( $tag ) {
- while ( $this->length() > 0 ) {
+ while ( $this->currentNode ) {
if ( $this->currentNode->isA( $tag ) ) {
$this->pop();
break;
*/
public function clearToContext( $set ) {
// Note that we don't loop to 0. Never pop the <html> elt off.
- while ( $this->length() > 1 ) {
+ for ( $length = count( $this->elements ); $length > 1; $length-- ) {
if ( $this->currentNode->isA( $set ) ) {
break;
}