Skip to content

Selection.modify() taking optional strings doesn't make sense to me #346

@emilio

Description

@emilio

https://w3c.github.io/selection-api/#dom-selection-modify says:

undefined modify(optional DOMString alter, optional DOMString direction, optional DOMString granularity);

However it also says:

If alter is not ASCII case-insensitive match with "extend" or "move", abort these steps.
If direction is not ASCII case-insensitive match with "forward", "backward", "left", or "right", abort these steps.
If granularity is not ASCII case-insensitive match with "character", "word", "sentence", "line", "paragraph", "lineboundary", "sentenceboundary", "paragraphboundary", "documentboundary", abort these steps.

So, basically, it early returns without errors if any of the arguments don't match. That doesn't make a lot of sense to me.

That seems to match WebKit and Blink's implementation. Gecko however throws a reasonable error and makes the strings mandatory.

I think the Gecko behavior is preferable, but if we're going with the "silent error" behavior of WebKit / Blink, maybe we should clarify it as a compatibility quirk (since it's really odd).

cc @rniwa @smaug---- @foolip

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