Skip to content

Element.children.insertAll() fails with 'Unsupported operation: Cannot resize element lists'. #15372

Open
@DartBot

Description

This issue was originally filed by greg.lowe...@gmail.com


Element.children.insertAll() fails with 'Unsupported operation: Cannot resize element lists'. See the example program below.

This happens because ListMixin.insertAll() increases the length via the List.length setter which is not supported by ChildElementList.

However it should be possible for the ChildElementList to provide it's own implementation of insertAll() which works as expected.

import 'dart:html';

main() {
  var el = new Element.div();
  document.body.children.add(el);

  el.children.addAll([
      new Element.div()..text = 'a',
      new Element.div()..text = 'b',
      new Element.div()..text = 'c']);

  el.children.insert(2, new Element.div()..text = '1');

  el.children.insertAll(2, [new Element.div()..text = '1', new Element.div()..text = '2']);
}

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onarea-webUse area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop.library-htmltype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)web-librariesIssues impacting dart:html, etc., libraries

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions