@@ -422,7 +422,7 @@ class WP_HTML_Tag_Processor {
422
422
* @since 6.2.0
423
423
* @var WP_HTML_Text_Replacement[]
424
424
*/
425
- private $ attribute_updates = array ();
425
+ private $ lexical_updates = array ();
426
426
427
427
/**
428
428
* Tracks how many times we've performed a `seek()`
@@ -1096,15 +1096,15 @@ private function skip_whitespace() {
1096
1096
}
1097
1097
1098
1098
/**
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.
1100
1100
*
1101
1101
* @since 6.2.0
1102
1102
*
1103
1103
* @return void
1104
1104
*/
1105
1105
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 ();
1108
1108
$ this ->tag_name_starts_at = null ;
1109
1109
$ this ->tag_name_length = null ;
1110
1110
$ this ->tag_ends_at = null ;
@@ -1113,20 +1113,20 @@ private function after_tag() {
1113
1113
}
1114
1114
1115
1115
/**
1116
- * Converts class name updates into tag attributes updates
1116
+ * Converts class name updates into tag lexical updates
1117
1117
* (they are accumulated in different data formats for performance).
1118
1118
*
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.
1120
1120
* The behavior in all other cases is undefined.
1121
1121
*
1122
1122
* @return void
1123
1123
* @since 6.2.0
1124
1124
*
1125
1125
* @see $classname_updates
1126
- * @see $attribute_updates
1126
+ * @see $lexical_updates
1127
1127
*/
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 ' ] ) ) {
1130
1130
$ this ->classname_updates = array ();
1131
1131
return ;
1132
1132
}
@@ -1246,13 +1246,13 @@ private function class_name_updates_to_attributes_updates() {
1246
1246
*
1247
1247
* @since 6.2.0
1248
1248
*/
1249
- private function apply_attributes_updates () {
1250
- if ( ! count ( $ this ->attribute_updates ) ) {
1249
+ private function apply_lexical_updates () {
1250
+ if ( ! count ( $ this ->lexical_updates ) ) {
1251
1251
return ;
1252
1252
}
1253
1253
1254
1254
/**
1255
- * Attribute updates can be enqueued in any order but as we
1255
+ * Lexical updates can be enqueued in any order but as we
1256
1256
* progress through the document to replace them we have to
1257
1257
* make our replacements in the order in which they are found
1258
1258
* in that document.
@@ -1261,25 +1261,25 @@ private function apply_attributes_updates() {
1261
1261
* out of order, which could otherwise lead to mangled output,
1262
1262
* partially-duplicate attributes, and overwritten attributes.
1263
1263
*/
1264
- usort ( $ this ->attribute_updates , array ( self ::class, 'sort_start_ascending ' ) );
1264
+ usort ( $ this ->lexical_updates , array ( self ::class, 'sort_start_ascending ' ) );
1265
1265
1266
- foreach ( $ this ->attribute_updates as $ diff ) {
1266
+ foreach ( $ this ->lexical_updates as $ diff ) {
1267
1267
$ this ->updated_html .= substr ( $ this ->html , $ this ->updated_bytes , $ diff ->start - $ this ->updated_bytes );
1268
1268
$ this ->updated_html .= $ diff ->text ;
1269
1269
$ this ->updated_bytes = $ diff ->end ;
1270
1270
}
1271
1271
1272
1272
foreach ( $ this ->bookmarks as $ bookmark ) {
1273
1273
/**
1274
- * As we loop through $this->attribute_updates , we keep comparing
1274
+ * As we loop through $this->lexical_updates , we keep comparing
1275
1275
* $bookmark->start and $bookmark->end to $diff->start. We can't
1276
1276
* change it and still expect the correct result, so let's accumulate
1277
1277
* the deltas separately and apply them all at once after the loop.
1278
1278
*/
1279
1279
$ head_delta = 0 ;
1280
1280
$ tail_delta = 0 ;
1281
1281
1282
- foreach ( $ this ->attribute_updates as $ diff ) {
1282
+ foreach ( $ this ->lexical_updates as $ diff ) {
1283
1283
$ update_head = $ bookmark ->start >= $ diff ->start ;
1284
1284
$ update_tail = $ bookmark ->end >= $ diff ->start ;
1285
1285
@@ -1302,7 +1302,7 @@ private function apply_attributes_updates() {
1302
1302
$ bookmark ->end += $ tail_delta ;
1303
1303
}
1304
1304
1305
- $ this ->attribute_updates = array ();
1305
+ $ this ->lexical_updates = array ();
1306
1306
}
1307
1307
1308
1308
/**
@@ -1345,8 +1345,8 @@ public function seek( $bookmark_name ) {
1345
1345
*
1346
1346
* @since 6.2.0
1347
1347
*
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.
1350
1350
* @return integer
1351
1351
*/
1352
1352
private static function sort_start_ascending ( $ a , $ b ) {
@@ -1604,8 +1604,8 @@ public function set_attribute( $name, $value ) {
1604
1604
*
1605
1605
* Result: <div id="new"/>
1606
1606
*/
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 (
1609
1609
$ existing_attribute ->start ,
1610
1610
$ existing_attribute ->end ,
1611
1611
$ updated_attribute
@@ -1622,7 +1622,7 @@ public function set_attribute( $name, $value ) {
1622
1622
*
1623
1623
* Result: <div id="new"/>
1624
1624
*/
1625
- $ this ->attribute_updates [ $ comparable_name ] = new WP_HTML_Text_Replacement (
1625
+ $ this ->lexical_updates [ $ comparable_name ] = new WP_HTML_Text_Replacement (
1626
1626
$ this ->tag_name_starts_at + $ this ->tag_name_length ,
1627
1627
$ this ->tag_name_starts_at + $ this ->tag_name_length ,
1628
1628
' ' . $ updated_attribute
@@ -1662,7 +1662,7 @@ public function remove_attribute( $name ) {
1662
1662
*
1663
1663
* Result: <div />
1664
1664
*/
1665
- $ this ->attribute_updates [ $ name ] = new WP_HTML_Text_Replacement (
1665
+ $ this ->lexical_updates [ $ name ] = new WP_HTML_Text_Replacement (
1666
1666
$ this ->attributes [ $ name ]->start ,
1667
1667
$ this ->attributes [ $ name ]->end ,
1668
1668
''
@@ -1724,7 +1724,7 @@ public function __toString() {
1724
1724
*/
1725
1725
public function get_updated_html () {
1726
1726
// 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 ) ) {
1728
1728
return $ this ->updated_html . substr ( $ this ->html , $ this ->updated_bytes );
1729
1729
}
1730
1730
@@ -1737,8 +1737,8 @@ public function get_updated_html() {
1737
1737
$ updated_html_up_to_current_tag_name_end = $ this ->updated_html . $ delta_between_updated_html_end_and_current_tag_end ;
1738
1738
1739
1739
// 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 ();
1742
1742
1743
1743
// 2. Replace the original HTML with the updated HTML
1744
1744
$ this ->html = $ this ->updated_html . substr ( $ this ->html , $ this ->updated_bytes );
0 commit comments