- Timestamp:
- 03/12/2024 02:25:30 PM (20 months ago)
- Location:
- branches/6.5
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/wp-includes/html-api/class-wp-html-tag-processor.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/6.5
-
branches/6.5/src/wp-includes/html-api/class-wp-html-tag-processor.php
r57738 r57815 838 838 */ 839 839 public function next_token() { 840 return $this->base_class_next_token(); 841 } 842 843 /** 844 * Internal method which finds the next token in the HTML document. 845 * 846 * This method is a protected internal function which implements the logic for 847 * finding the next token in a document. It exists so that the parser can update 848 * its state without affecting the location of the cursor in the document and 849 * without triggering subclass methods for things like `next_token()`, e.g. when 850 * applying patches before searching for the next token. 851 * 852 * @since 6.5.0 853 * 854 * @access private 855 * 856 * @return bool Whether a token was parsed. 857 */ 858 private function base_class_next_token() { 840 859 $was_at = $this->bytes_already_parsed; 841 $this-> get_updated_html();860 $this->after_tag(); 842 861 843 862 // Don't proceed if there's nothing more to scan. … … 2042 2061 */ 2043 2062 private function after_tag() { 2063 /* 2064 * There could be lexical updates enqueued for an attribute that 2065 * also exists on the next tag. In order to avoid conflating the 2066 * attributes across the two tags, lexical updates with names 2067 * need to be flushed to raw lexical updates. 2068 */ 2069 $this->class_name_updates_to_attributes_updates(); 2070 2071 /* 2072 * Purge updates if there are too many. The actual count isn't 2073 * scientific, but a few values from 100 to a few thousand were 2074 * tests to find a practially-useful limit. 2075 * 2076 * If the update queue grows too big, then the Tag Processor 2077 * will spend more time iterating through them and lose the 2078 * efficiency gains of deferring applying them. 2079 */ 2080 if ( 1000 < count( $this->lexical_updates ) ) { 2081 $this->get_updated_html(); 2082 } 2083 2084 foreach ( $this->lexical_updates as $name => $update ) { 2085 /* 2086 * Any updates appearing after the cursor should be applied 2087 * before proceeding, otherwise they may be overlooked. 2088 */ 2089 if ( $update->start >= $this->bytes_already_parsed ) { 2090 $this->get_updated_html(); 2091 break; 2092 } 2093 2094 if ( is_int( $name ) ) { 2095 continue; 2096 } 2097 2098 $this->lexical_updates[] = $update; 2099 unset( $this->lexical_updates[ $name ] ); 2100 } 2101 2044 2102 $this->token_starts_at = null; 2045 2103 $this->token_length = null; … … 2231 2289 2232 2290 // Adjust the cursor position by however much an update affects it. 2233 if ( $diff->start < =$this->bytes_already_parsed ) {2291 if ( $diff->start < $this->bytes_already_parsed ) { 2234 2292 $this->bytes_already_parsed += $shift; 2235 2293 } … … 3165 3223 */ 3166 3224 $this->bytes_already_parsed = $before_current_tag; 3167 $this->parse_next_tag(); 3168 // Reparse the attributes. 3169 while ( $this->parse_next_attribute() ) { 3170 continue; 3171 } 3172 3173 $tag_ends_at = strpos( $this->html, '>', $this->bytes_already_parsed ); 3174 $this->token_length = $tag_ends_at - $this->token_starts_at; 3175 $this->bytes_already_parsed = $tag_ends_at; 3225 $this->base_class_next_token(); 3176 3226 3177 3227 return $this->html;
Note: See TracChangeset
for help on using the changeset viewer.