Polymer: template dom-if overrides e.model in poylmer 1.0

Created on 14 Jun 2015  Â·  12Comments  Â·  Source: Polymer/polymer

in this example:

    <template is="dom-repeat" items="{{items}}">
        <div>
            <span>{{item}}</span>
            <template is="dom-if" if="{{admin}}">
                <span on-tap="remove">REMOVE</span>
            </template>
        </div>
    </template>

the remove event can not access e.model.item. Is this intended? It would be great if e.model provided access to the all the models, including for nested repeats.

I know there is a workaround by id-ing the repeat and using modelForElement(e.target) but this is really inconvenient.

1.x enhancement p2

Most helpful comment

Looks like it is indeed working fine in 2.x

P.S. Thanks @TimvdLippe for cleaning old issues!

All 12 comments

Short-term, you can use dom-repeat's modelForElement API to get the model for the dom-repeat from the event:
http://jsbin.com/lefuxi/edit?html,console,output

Longer-term, we'll investigate 2 more general fixes:

  • Make event.model specific to dom-repeat (currently model is added to all Templatizer instances, which is probably unnecessary (at least in the dom-if case)
  • Add a more user-friendly way to access outer dom-repeat scopes from events caught on inner socpes (right now you can do event.model.dataHost.dataHost.item, but this is too unwieldy).

Just stumbled upon this, really annoying one

@kevinpschaaf, what if I have nested dom-repeat > dom-repeat > dom-if?

This is almost 5 months old, can we expect some updates soon?

Just stumbled upon this.

any update on this issue?

I am unable to reproduce this problem in Polymer 2: http://jsbin.com/xocarojore/edit?html,console,output Could anyone also confirm this problem is fixed, just want to make sure the JSBin is correct?

Looks like it is indeed working fine in 2.x

P.S. Thanks @TimvdLippe for cleaning old issues!

@nazar-pc My pleasure! Thanks for your very quick confirmation, I can close another issue from the stack 😄

Please take me off this email list - I can find no way to unsubscribe.

On Mon, 21 Aug 2017 at 14:42, Tim van der Lippe notifications@github.com
wrote:

Closed #1585 https://github.com/Polymer/polymer/issues/1585.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/Polymer/polymer/issues/1585#event-1214168971, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABQQYUuiQCF-Ur0DgziJ5CuTZ4Df6Etoks5saYlSgaJpZM4EjmLK
.

On Mon, 21 Aug 2017 at 15:34, Tim van der Lippe notifications@github.com
wrote:

I am unable to reproduce this problem in Polymer 2:
http://jsbin.com/xocarojore/edit?html,console,output Could anyone also
confirm this problem is fixed, just want to make sure the JSBin is correct?

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/Polymer/polymer/issues/1865#issuecomment-323757992,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABQQYVa_hRrUHScM9oLRn3QMk_Hxu39Aks5saZTygaJpZM4FCkSp
.

>

Danny Clayden Chambers
Founder, Human First

@DannyChambers, you're likely watching Polymer project here on GitHub. Just select "Not watching" at the top right and you'll not get such emails anymore unless you're mentioned directly.

As mentioned in #2574 this is an issue in Polymer 1, surely neither this issue or the other should really have been closed? Can we expect a legacy patch for this?

Was this page helpful?
0 / 5 - 0 ratings