Dynamically adding polymer element which contains polymer-signals raises exception

Issue

With Polymer, I have implemented a custom form, which is using polymer_signals.html for listening to changes from arbitrary other polymer elements.

It is implemented like this:

<link rel="import" href="packages/polymer_elements/polymer_signals/polymer_signals.html">

<polymer-element name="user-settings" extends="form">
<template>
<polymer-signals on-polymer-signalauth-changed="{{onAuth}}"></polymer-signals>
...

This element is dynamically instantiated in a parent polymer element like this:

var userSettings = new Element.tag('form', 'user-settings');
$['main'].children.add(userSettings);

This raises the exception:

Exception: Concurrent modification during iteration: Instance(length:4) of '_GrowableList'._notify@0x1c4cf589 (http://127.0.0.1:3030/buddy/web/packages/polymer_elements/polymer_signals/polymer_signals.dart:39:12)
<anonymous closure> (http://127.0.0.1:3030/buddy/web/packages/polymer_elements/polymer_signals/polymer_signals.dart:49:12)

If I statically instantiate the polymer-form, I don’t get this error. How can I prevent this?

Solution

I can’t reproduce your problem.

There are two common things that are often missed

  1. if you have a custom main method
    see the answer to Polymer querySelector working on DartVM but not in Chrome after compile

  2. call of super.polymerCreated() in the constructor of elements that extend DOM elements.
    see the answer to Custom Polymer element extending AElement in Dart

If you still can’t solve the problem please add more code to your question (for example how your user-settings element looks like).

Answered By – Günter Zöchbauer

Answer Checked By – Jay B. (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *