Tools: linter warns on item property of vaadin-grid templates

Created on 9 May 2017  路  9Comments  路  Source: Polymer/tools

<vaadin-grid> uses the keyword item to represent iterated data points in it's grid templates, like so

  <vaadin-grid aria-label="Two-way Binding Example" items="[[users.result]]">

    <vaadin-grid-column>
      <template class="header">First Name</template>
      <template>
        <input value="{{item.firstName::input}}" readonly$="[[!editing]]">
      </template>
    </vaadin-grid-column>

    <vaadin-grid-column>
      <template class="header">Last Name</template>
      <template>
        <input value="{{item.lastName::input}}" readonly$="[[!editing]]">
      </template>
    </vaadin-grid-column>

    <vaadin-grid-column width="200px">
      <template class="header">Email</template>
      <template>
        <div>[[item.firstName]].[[item.lastName]]@example.com</div>
      </template>
    </vaadin-grid-column>

  </vaadin-grid>

The above example does not trigger linting errors, however, if [[item.prop]] is bound in a child template, polymer linter warns.

<vaadin-grid id="grid" name="grid" items="[[videos]]">

<vaadin-grid-column flex-grow="2">
  <template class="header">Title</template>
  <template>
    <span class="title">[[item.videoData.title]]</span>
    <template is="dom-if" if="[[!same(item.videoData.title, item.videoData.filename)]]" restamp="true">
      <span class="filename">[[item.videoData.filename]]</span>
    </template>
  </template>
</vaadin-grid-column>

in which case, the binding expression [[item.videoData.filename]] triggers a warning. item is not declared or used more than once.`

linter High Available Bug wontfix

All 9 comments

I'm also getting

      aria-label="[[gridDescription]]"
      ~~~~~~~~~~

mtz-group-list.html(33,6) warning [set-unknown-attribute] - vaadin-grid elements do not have a property named ariaLabel. Consider instead:  aria-label$

Please see #67

Hmmm #67 looks similar to the items issue however ariaLabel piece seems unrelated?

aria-label is not a property and therefore you should use attribute binfing there

You're right, maybe a better error message would be more useful.

I have the same error with this syntax:

<template is="dom-repeat" items="[[array]]" as="clipset" index-as="index">
  <paper-listbox name$="[[_getClipsetName(index, clipsets)]]" selected="{{clipIndex}}">
    <template is="dom-repeat" items="[[clipset]]" as="clip" index-as="makesError">
      <paper-item id="[[clip.id]]" on-tap="_handleTap">
        <span class="index">[[makesError]]</span>

For anyone arriving from Google, welcome 馃憢

In the meantime, I've disabled these warnings in CI by defining my lint script in my PSK app's package.json as such:

"lint": {
  "rules": ["polymer-2-hybrid"],
  "ignoreWarnings": ["databind-with-unknown-property"]
},

I'm not sure if this is the same issue but I'm having similar error message when using template inside another template.
Iron list uses <template> to generate list item and inside this template I am using item property that is used inside another template:

<iron-list>
  <template>
    <div>
      <span>[[item.property]] - this works here fine</span>
      <template is="dom-if" if="[[item.property]]">
         <span>[[item.property]] - this works here too but linter shows error</span>
      </template>
    </div>
  </template>
<iron-list>

image

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings