Skip to content

Polymer 0.8 cant bind to array item. #1409

Description

@mwinters-stuff

This we could do in 5.x

Using an array property/attribute which is populated with an 'associative' array of values, There is an error on the bind..

Eg.

Setup and element with a property (we are using this for translating the page)

  translations:{
          value: [],
          type: Array,
          notify: true,
          readOnly: true
        },

populate translations with an array of Objects. eg.

var trans = [];
trans['id-one'] = 'one';
trans['id-two'] = 'two';
this._setTranslations(trans);

Then

use the element.

    <translator-json translations="{{translations}}" ></translator-json>
    <paper-button raised="true">[[translations['id-one']]]</paper-button>
    <paper-button raised="true">[[translations['id-two']]]</paper-button>

Results in an error in bind.html
unexpectedIdentifier

it creates a setter

"var old = this._setData('translations['id-one']', value);
if (value !== old) {
  this._translations['id-one']Effector(old);
}"

Activity

  1. kevinpschaaf commented on May 22, 2015

    @kevinpschaaf
    Member

    We do not plan to support [...] bracket dereferencing in 0.8+, as we are avoiding use of a full JS expression parser for performance and simplicity.

    However, this syntax will work: [[translations.id-one]].

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