Make WordPress Core


Ignore:
Timestamp:
12/10/2023 01:17:29 PM (2 years ago)
Author:
zieladam
Message:

HTML API: Track spans of text with (offset, length) instead of (start, end).

Updates the internal representation of the text span coordinates. The mixture of (offset, length) and (start, end) coordinates becomes confusing, this commit replaces it with a (offset, length) pair. There should be no functional or behavioral changes in this patch. For the internal helper classes this patch introduces breaking changes, but those classes are marked private and should not be used outside of the HTML API itself.

Props dmsnell.
Fixes #59993.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/html-api/class-wp-html-span.php

    r55734 r57179  
    1919 * @access private
    2020 * @since 6.2.0
     21 * @since 6.5.0 Replaced `end` with `length` to more closely align with `substr()`.
    2122 *
    2223 * @see WP_HTML_Tag_Processor
     
    2728     *
    2829     * @since 6.2.0
     30     *
    2931     * @var int
    3032     */
     
    3234
    3335    /**
    34      * Byte offset into document where span ends.
     36     * Byte length of this span.
    3537     *
    36      * @since 6.2.0
     38     * @since 6.5.0
     39     *
    3740     * @var int
    3841     */
    39     public $end;
     42    public $length;
    4043
    4144    /**
     
    4447     * @since 6.2.0
    4548     *
    46      * @param int $start Byte offset into document where replacement span begins.
    47      * @param int $end   Byte offset into document where replacement span ends.
     49     * @param int $start  Byte offset into document where replacement span begins.
     50     * @param int $length Byte length of span.
    4851     */
    49     public function __construct( $start, $end ) {
    50         $this->start = $start;
    51         $this->end   = $end;
     52    public function __construct( $start, $length ) {
     53        $this->start  = $start;
     54        $this->length = $length;
    5255    }
    5356}
Note: See TracChangeset for help on using the changeset viewer.