private function normalizeAttributes($source, HtmlTokenizer $tokenizer)
    {
        $result = '';
        foreach ($tokenizer->parse($source) as $token) {
            if (empty($token[HtmlTokenizer::TOKEN_ATTRIBUTES])) {
                $result .= $tokenizer->compileToken($token);
                continue;
            }

            $attributes = [];
            foreach ($token[HtmlTokenizer::TOKEN_ATTRIBUTES] as $attribute => $value) {
                if (in_array($attribute, $this->options['attributes']['trim'])) {
                    $value = trim($value);
                }

                if (empty($value) && in_array($attribute, $this->options['attributes']['drop'])) {
                    //Empty value
                    continue;
                }

                $attributes[$attribute] = $value;
            }

            $token[HtmlTokenizer::TOKEN_ATTRIBUTES] = $attributes;
            $result .= $tokenizer->compileToken($token);
        }

        return $result;
    }
private function normalizeAttributes($source, HtmlTokenizer $tokenizer)
    {
        $result = '';
        foreach ($tokenizer->parse($source) as $token) {
            if (empty($token[HtmlTokenizer::TOKEN_ATTRIBUTES])) {
                $result .= $tokenizer->compileToken($token);
                continue;
            }

            $attributes = [];
            foreach ($token[HtmlTokenizer::TOKEN_ATTRIBUTES] as $attribute => $value) {
                if (in_array($attribute, $this->options['attributes']['trim'])) {
                    $value = trim($value);
                }

                if (empty($value) && in_array($attribute, $this->options['attributes']['drop'])) {
                    //Empty value
                    continue;
                }

                $attributes[$attribute] = $value;
            }

            $token[HtmlTokenizer::TOKEN_ATTRIBUTES] = $attributes;
            $result .= $tokenizer->compileToken($token);
        }

        return $result;
    }
private function normalizeAttributes ( $ source , HtmlTokenizer $ tokenizer ) { $ result = '' ; foreach ( $ tokenizer -> parse ( $ source ) as $ token ) { if ( empty ( $ token [ HtmlTokenizer :: TOKEN_ATTRIBUTES ] ) ) { $ result .= $ tokenizer -> compileToken ( $ token ) ; continue ; } $ attributes = [ ] ; foreach ( $ token [ HtmlTokenizer :: TOKEN_ATTRIBUTES ] as $ attribute => $ value ) { if ( in_array ( $ attribute , $ this -> options [ 'attributes' ] [ 'trim' ] ) ) { $ value = trim ( $ value ) ; } if ( empty ( $ value ) && in_array ( $ attribute , $ this -> options [ 'attributes' ] [ 'drop' ] ) ) { //Empty value continue ; } $ attributes [ $ attribute ] = $ value ; } $ token [ HtmlTokenizer :: TOKEN_ATTRIBUTES ] = $ attributes ; $ result .= $ tokenizer -> compileToken ( $ token ) ; } return $ result ; }
Normalize attribute values.

@param string        $source
@param HtmlTokenizer $tokenizer

@return mixed
Normalize attribute values .