@@ -422,7 +422,7 @@ class WP_HTML_Tag_Processor {
422422 * @since 6.2.0
423423 * @var WP_HTML_Text_Replacement[]
424424 */
425- private $ attribute_updates = array ();
425+ private $ lexical_updates = array ();
426426
427427 /**
428428 * Tracks how many times we've performed a `seek()`
@@ -1096,15 +1096,15 @@ private function skip_whitespace() {
10961096 }
10971097
10981098 /**
1099- * Applies attribute updates and cleans up once a tag is fully parsed.
1099+ * Applies lexical updates and cleans up once a tag is fully parsed.
11001100 *
11011101 * @since 6.2.0
11021102 *
11031103 * @return void
11041104 */
11051105 private function after_tag () {
1106- $ this ->class_name_updates_to_attributes_updates ();
1107- $ this ->apply_attributes_updates ();
1106+ $ this ->class_name_updates_to_lexical_updates ();
1107+ $ this ->apply_lexical_updates ();
11081108 $ this ->tag_name_starts_at = null ;
11091109 $ this ->tag_name_length = null ;
11101110 $ this ->tag_ends_at = null ;
@@ -1113,20 +1113,20 @@ private function after_tag() {
11131113 }
11141114
11151115 /**
1116- * Converts class name updates into tag attributes updates
1116+ * Converts class name updates into tag lexical updates
11171117 * (they are accumulated in different data formats for performance).
11181118 *
1119- * This method is only meant to run right before the attribute updates are applied.
1119+ * This method is only meant to run right before the lexical updates are applied.
11201120 * The behavior in all other cases is undefined.
11211121 *
11221122 * @return void
11231123 * @since 6.2.0
11241124 *
11251125 * @see $classname_updates
1126- * @see $attribute_updates
1126+ * @see $lexical_updates
11271127 */
1128- private function class_name_updates_to_attributes_updates () {
1129- if ( count ( $ this ->classname_updates ) === 0 || isset ( $ this ->attribute_updates ['class ' ] ) ) {
1128+ private function class_name_updates_to_lexical_updates () {
1129+ if ( count ( $ this ->classname_updates ) === 0 || isset ( $ this ->lexical_updates ['class ' ] ) ) {
11301130 $ this ->classname_updates = array ();
11311131 return ;
11321132 }
@@ -1246,13 +1246,13 @@ private function class_name_updates_to_attributes_updates() {
12461246 *
12471247 * @since 6.2.0
12481248 */
1249- private function apply_attributes_updates () {
1250- if ( ! count ( $ this ->attribute_updates ) ) {
1249+ private function apply_lexical_updates () {
1250+ if ( ! count ( $ this ->lexical_updates ) ) {
12511251 return ;
12521252 }
12531253
12541254 /**
1255- * Attribute updates can be enqueued in any order but as we
1255+ * Lexical updates can be enqueued in any order but as we
12561256 * progress through the document to replace them we have to
12571257 * make our replacements in the order in which they are found
12581258 * in that document.
@@ -1261,25 +1261,25 @@ private function apply_attributes_updates() {
12611261 * out of order, which could otherwise lead to mangled output,
12621262 * partially-duplicate attributes, and overwritten attributes.
12631263 */
1264- usort ( $ this ->attribute_updates , array ( self ::class, 'sort_start_ascending ' ) );
1264+ usort ( $ this ->lexical_updates , array ( self ::class, 'sort_start_ascending ' ) );
12651265
1266- foreach ( $ this ->attribute_updates as $ diff ) {
1266+ foreach ( $ this ->lexical_updates as $ diff ) {
12671267 $ this ->updated_html .= substr ( $ this ->html , $ this ->updated_bytes , $ diff ->start - $ this ->updated_bytes );
12681268 $ this ->updated_html .= $ diff ->text ;
12691269 $ this ->updated_bytes = $ diff ->end ;
12701270 }
12711271
12721272 foreach ( $ this ->bookmarks as $ bookmark ) {
12731273 /**
1274- * As we loop through $this->attribute_updates , we keep comparing
1274+ * As we loop through $this->lexical_updates , we keep comparing
12751275 * $bookmark->start and $bookmark->end to $diff->start. We can't
12761276 * change it and still expect the correct result, so let's accumulate
12771277 * the deltas separately and apply them all at once after the loop.
12781278 */
12791279 $ head_delta = 0 ;
12801280 $ tail_delta = 0 ;
12811281
1282- foreach ( $ this ->attribute_updates as $ diff ) {
1282+ foreach ( $ this ->lexical_updates as $ diff ) {
12831283 $ update_head = $ bookmark ->start >= $ diff ->start ;
12841284 $ update_tail = $ bookmark ->end >= $ diff ->start ;
12851285
@@ -1302,7 +1302,7 @@ private function apply_attributes_updates() {
13021302 $ bookmark ->end += $ tail_delta ;
13031303 }
13041304
1305- $ this ->attribute_updates = array ();
1305+ $ this ->lexical_updates = array ();
13061306 }
13071307
13081308 /**
@@ -1345,8 +1345,8 @@ public function seek( $bookmark_name ) {
13451345 *
13461346 * @since 6.2.0
13471347 *
1348- * @param WP_HTML_Text_Replacement $a First attribute update.
1349- * @param WP_HTML_Text_Replacement $b Second attribute update.
1348+ * @param WP_HTML_Text_Replacement $a First lexical update.
1349+ * @param WP_HTML_Text_Replacement $b Second lexical update.
13501350 * @return integer
13511351 */
13521352 private static function sort_start_ascending ( $ a , $ b ) {
@@ -1604,8 +1604,8 @@ public function set_attribute( $name, $value ) {
16041604 *
16051605 * Result: <div id="new"/>
16061606 */
1607- $ existing_attribute = $ this ->attributes [ $ comparable_name ];
1608- $ this ->attribute_updates [ $ name ] = new WP_HTML_Text_Replacement (
1607+ $ existing_attribute = $ this ->attributes [ $ comparable_name ];
1608+ $ this ->lexical_updates [ $ name ] = new WP_HTML_Text_Replacement (
16091609 $ existing_attribute ->start ,
16101610 $ existing_attribute ->end ,
16111611 $ updated_attribute
@@ -1622,7 +1622,7 @@ public function set_attribute( $name, $value ) {
16221622 *
16231623 * Result: <div id="new"/>
16241624 */
1625- $ this ->attribute_updates [ $ comparable_name ] = new WP_HTML_Text_Replacement (
1625+ $ this ->lexical_updates [ $ comparable_name ] = new WP_HTML_Text_Replacement (
16261626 $ this ->tag_name_starts_at + $ this ->tag_name_length ,
16271627 $ this ->tag_name_starts_at + $ this ->tag_name_length ,
16281628 ' ' . $ updated_attribute
@@ -1662,7 +1662,7 @@ public function remove_attribute( $name ) {
16621662 *
16631663 * Result: <div />
16641664 */
1665- $ this ->attribute_updates [ $ name ] = new WP_HTML_Text_Replacement (
1665+ $ this ->lexical_updates [ $ name ] = new WP_HTML_Text_Replacement (
16661666 $ this ->attributes [ $ name ]->start ,
16671667 $ this ->attributes [ $ name ]->end ,
16681668 ''
@@ -1724,7 +1724,7 @@ public function __toString() {
17241724 */
17251725 public function get_updated_html () {
17261726 // Short-circuit if there are no new updates to apply.
1727- if ( ! count ( $ this ->classname_updates ) && ! count ( $ this ->attribute_updates ) ) {
1727+ if ( ! count ( $ this ->classname_updates ) && ! count ( $ this ->lexical_updates ) ) {
17281728 return $ this ->updated_html . substr ( $ this ->html , $ this ->updated_bytes );
17291729 }
17301730
@@ -1737,8 +1737,8 @@ public function get_updated_html() {
17371737 $ updated_html_up_to_current_tag_name_end = $ this ->updated_html . $ delta_between_updated_html_end_and_current_tag_end ;
17381738
17391739 // 1. Apply the attributes updates to the original HTML
1740- $ this ->class_name_updates_to_attributes_updates ();
1741- $ this ->apply_attributes_updates ();
1740+ $ this ->class_name_updates_to_lexical_updates ();
1741+ $ this ->apply_lexical_updates ();
17421742
17431743 // 2. Replace the original HTML with the updated HTML
17441744 $ this ->html = $ this ->updated_html . substr ( $ this ->html , $ this ->updated_bytes );
0 commit comments