Skip to content

getTotalLength() in the context of textPath element with an href #1178

Open

Description

@karlcow

This is a sub-issue for #1175.
The issue considers adding getTotalLength() to a textPath element.

The proposal says the new members apply to the path attribute. But href is the older, far more common (and currently interoperable) form.

So an author who reads "textPath now has getTotalLength" and calls it on this:

<text><textPath href="#wave">Curving text</textPath></text>

gets 0. Not an error, not a warning.

  • And getPathData() gives an empty list,
  • and getPathSegmentAtLength() gives null.

The referenced element is itself measurable, so the information is there but not directly accessible, which is what the method is saying.

If path attribute is present but empty, the spec says rendering falls back to href. The API would not follow that fallback. So the text is visibly sitting on a curve while getTotalLength() reports 0.

The rendering and the API would give different results for the same element.

How should this be solved?
If not solved, it would create complexity.

Activity

  1. longsonr commented on Sep 13, 2026

    @longsonr
    Contributor

    I guess the options are

    1. throw
    2. return 0 or null
    3. return the data for the path the href points to in that case.

    3 might be most useful as you could just call the API whatever the definition of the textPath.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions