HTML::O...ableRow(3)

πŸ“¦ version 0.6.0, in alpine 3.24

🌸 HTML::Object::DOM::Element::TableRow 🌸

Okay bestie, so this is a page from the User Contributed Perl Documentation set β€” the HTML::O...ableRow(3) girlies β€” and it's literally all about HTML::Object::DOM::Element::TableRow, the class that handles table rows. Come sit with me, this is gonna be a fun one πŸ’–


✨ NAME ✨

HTML::Object::DOM::Element::TableRow β€” the HTML Object DOM TableRow Class. That's her. That's the whole name. Iconic, honestly πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

use HTML::Object::DOM::Element::TableRow;
my $tablerow = HTML::Object::DOM::Element::TableRow->new ||
    die( HTML::Object::DOM::Element::TableRow->error, "\n" );

Like, that's it. That's the whole vibe. new it up or die with the error, periodt πŸ’…


πŸ¦‹ VERSION πŸ¦‹

v0.2.0

Version v0.2.0, bestie. We're on the current era ✨


🌈 DESCRIPTION 🌈

So this interface hands you special properties and methods β€” like, on top of the HTML::Object::DOM::Element interface it already inherits from, no cap β€” for manipulating the layout and presentation of rows (the "tr" girlies) inside an HTML table. That's the whole job. Rows. Layout. Presentation. Slay 🫢


πŸ‘‘ INHERITANCE πŸ‘‘

Look at this family tree, it's giving royal lineage:

+-----------------------+     +---------------------------+     +-------------------------+     +----------------------------+     +--------------------------------------+
| HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::TableRow |
+-----------------------+     +---------------------------+     +-------------------------+     +----------------------------+     +--------------------------------------+

Five generations deep and every single one of them ate πŸ’€


πŸ’œ PROPERTIES πŸ’œ

She inherits properties from her parent, HTML::Object::DOM::Element. Standard nepo-baby behaviour, but make it useful.

πŸ“ cells πŸ“

Read-only.

Returns a collection containing the cells in the row β€” but only the ones directly under the row element. No searching through the descendants, she's not doing all that.

Lowkey important: for performance improvement, the collection is cached until changes are made that would affect the results. So it's fast, but like, don't be weird about it.

Example:

<table id="myTable1">
    <tr>
        <td>
            <table id="myTable2">
                <tr><td></td></tr>
            </table>
        </td>
        <td></td>
    </tr>
</table>

say getElementById('myTable1')->rows->[0]->cells->length; # 2
say getElementById('myTable2')->rows->[0]->cells->length; # 1

See the difference? 2 and 1. The way that nesting actually matters here 😭

See also the Mozilla documentation: <https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableRowElement/cells>

🧚 rowIndex 🧚

Read-only.

Returns a long value which gives the logical position of the row within the entire table. If the row is not part of a table, it returns "undef" (which is -1 under JavaScript β€” iykyk).

Example:

<table>
    <thead>
        <tr><th>Item</th>        <th>Price</th></tr>
    </thead>
    <tbody>
        <tr><td>Bananas</td>     <td>$2</td></tr>
        <tr><td>Oranges</td>     <td>$8</td></tr>
        <tr><td>Top Sirloin</td> <td>$20</td></tr>
    </tbody>
    <tfoot>
        <tr><td>Total</td>       <td>$30</td></tr>
    </tfoot>
</table>

Another example:

my $rows = $doc->querySelectorAll('tr');

$rows->forEach(sub
{
    my $row = shift( @_ );
    my $z = $doc->createElement('td');
    $z->textContent = "(row #" . $row->rowIndex . ")";
    row->appendChild($z);
});

(Yes, that last line is exactly what the docs say. Copy it character for character, bestie, don't come for me πŸ™ˆ)

See also the Mozilla documentation: <https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableRowElement/rowIndex>

🌸 sectionRowIndex 🌸

Read-only.

Returns a long value which gives the logical position of the row within the table section it belongs to. If the row is not part of a section, it returns "undef" (-1 under JavaScript, same energy as before).

See also the Mozilla documentation: <https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableRowElement/sectionRowIndex>


πŸ”₯ METHODS πŸ”₯

Inherits methods from her parent, HTML::Object::DOM::Element. Again. Nepo baby. Love her anyway πŸ’–

⭐ deleteCell ⭐

Removes the cell corresponding to the "index" given in the parameter. Here's the little rulebook so you don't fumble it:

  • If the "index" value is -1, the last cell is removed.
  • If it's smaller than -1, or greater than the amount of cells in the collection, an "HTML::Object::IndexSizeError" is returned. So like, be normal about the index, okay? 😭

See also the Mozilla documentation: <https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableRowElement/deleteCell>

πŸ’« insertCell πŸ’«

Returns an HTML::Object::DOM::Element::TableCell representing a new cell of the table. It inserts it in the cells collection immediately before a "td" or "th" element at the given "index" position, if any was provided.

The index tea β˜•:

  • If the "index" is not given or is -1, the new cell is appended to the collection.
  • If the "index" is smaller than -1, it will start that far back from the end of the collection array.
  • If "index" is greater than the number of cells in the collection, an "HTML::Object::IndexSizeError" error is returned. Same error girl as before, she gets around.

Example:

<table id="my-table">
    <tr><td>Row 1</td></tr>
    <tr><td>Row 2</td></tr>
    <tr><td>Row 3</td></tr>
</table>
sub addRow
{
    my $tableID = shift( @_ );
    # Get a reference to the table
    my $tableRef = $doc->getElementById( $tableID );

    # Insert a row at the end of the table
    my $newRow = $tableRef->insertRow( -1 );

    # Insert a cell in the row at index 0
    my $newCell = $newRow->insertCell( 0 );

    # Append a text node to the cell
    my $newText = $doc->createTextNode('New bottom row');
    $newCell->appendChild( $newText );
}

# Call addRow() with the table's ID
addRow( 'my-table' );

See also the Mozilla documentation: <https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableRowElement/insertCell>


πŸ’€ DEPRECATED PROPERTIES πŸ’€

Okay so heads up bestie β€” everything in this section is deprecated. It's the old stuff. It still exists, the docs still document it, but don't build your whole personality on it, you feel me? πŸ™ˆ

🌺 align 🌺

Is a string containing an enumerated value reflecting the align attribute. It indicates the alignment of the element's contents with respect to the surrounding context. The possible values are "left", "right", and "center". Three choices, that's the whole menu πŸ’…

See also the Mozilla documentation: <https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableRowElement/align>

πŸŽ€ bgColor πŸŽ€

Is a string containing the background color of the cells. It reflects the obsolete bgcolor attribute. Obsolete! We said it! 🌈

See also the Mozilla documentation: <https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableRowElement/bgColor>

πŸŽ€ bgcolor πŸŽ€

Alias for "bgColor". Same girl, lowercase outfit.

πŸ¦‹ ch πŸ¦‹

Is a string containing one single character. This character is the one to align all the cell of a column on. It reflects the char and defaults to the decimal points associated with the language, e.g. '.' for English, or ',' for French. This property was optional and was not very well supported. Respect the honest documentation, honestly 🫢

See also the Mozilla documentation: <https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableRowElement/ch>

πŸ¦‹ chOff πŸ¦‹

Is a string containing a integer indicating how many characters must be left at the right (for left-to-right scripts; or at the left for right-to-left scripts) of the character defined by HTML::Object::DOM::Element::"TableRow".ch. This property was optional and was not very well supported either. Two for two, iconic flop era 😭

See also the Mozilla documentation: <https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableRowElement/chOff>

πŸ¦‹ choff πŸ¦‹

Alias for "chOff". Lowercase again, you know the drill.

⭐ reset ⭐

When called, this will set a boolean value indicating the cached data must be recomputed. This allow the saving of computational power, β€” yes, the sentence ends right there in the original, and I'm not about to invent an ending for it. Mysterious queen energy πŸ’€

🌸 vAlign 🌸

Is a string representing an enumerated value indicating how the content of the cell must be vertically aligned. It reflects the valign attribute and can have one of the following values: "top", "middle", "bottom", or "baseline". Four options, pick one 🎯

See also the Mozilla documentation: <https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableRowElement/vAlign>

🌸 valign 🌸

Alias for "vAlign". You already knew that.


🫢 AUTHOR 🫢

Jacques Deguest <jack@deguest.jp> β€” the actual main character who wrote all of this πŸ’–


πŸ’œ SEE ALSO πŸ’œ

Go read them, bestie, they're literally right there πŸ“š


Copyright(c) 2022 DEGUEST Pte. Ltd.

All rights reserved

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


✨ and that's the whole page, bestie ✨ Brought to you by perl v5.42.2, dated 2026-02-15, from the HTML::O...ableRow(3) manual β€” go forth and build tables that slay πŸ’…πŸŽ€
πŸ“¦ where this page comes from