Skip to content

Give insertBefore a Node or null as anchor #2573

@EmilTholin

Description

@EmilTholin

referenceNode is not an optional parameter -- you must explicitly pass a Node or null. Failing to provide it or passing invalid values may behave differently in different browser versions.

This throws an error in IE9 and 10, so it might be worth defaulting the anchor component option to null:

mount_component(component, options.target, options.anchor || null);

Or possibly defaulting it at insert:

export function insert(target, node, anchor) {
  target.insertBefore(node, anchor || null);
}

I'm not sure what's best, so I thought I'd open an issue and discuss it before creating a PR.

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