polymer icon indicating copy to clipboard operation
polymer copied to clipboard

`notifyPath` after a property is `delete`d

Open David-Mulder opened this issue 11 years ago • 7 comments

notifyPath seems to first check for changes and if it doesn't find changes it won't do anything. If we delete a property on an object and next trigger

this.notifyPath('object', this.object);

nothing will happen, so it would be useful to either have a force flag on notifyPath, or alternatively have it properly realize something changed at least.

David-Mulder avatar Oct 26 '15 19:10 David-Mulder

related https://github.com/Polymer/polymer/issues/2447, https://github.com/Polymer/polymer/issues/2565

samccone avatar Oct 26 '15 20:10 samccone

I suggest generalising this to any case of object properties change without reference change. I have a case where I want to notifyPath on multiple properties at a time, and currently this is not possible. I propose adding something like this:

this.notifyPath('obj.*', obj);

which would make notifyPath bypass the reference equality check and would work for multiple properties change and deletion.

GabiAxel avatar Dec 09 '15 09:12 GabiAxel

I would find this useful as well. In my case I am changing multiple properties on an array element provided by an external library, but I am not adding or removing any array elements. As it stands right now I have to call notifyPath for each changed property. A single call would be preferable.

kwaclaw avatar Apr 04 '16 21:04 kwaclaw

This would be usefull to me too. I'am working with json schema and I sometime need to delete properties. I also suggest something like this: this.delete('parentProperty.childProperty'); (since there's no value to notify, we need another pipeline for this).

darkengines avatar Sep 14 '16 07:09 darkengines

Still an issue with Polymer 2: http://jsbin.com/dolukotoso/edit?html,console,output

TimvdLippe avatar Aug 10 '17 22:08 TimvdLippe

For the time being, here's what I use as a workaround:

delete this.objectName[propertyName];
this.notifyPath(`objectName.${propertyName}`, false)

merlinnot avatar Aug 26 '17 14:08 merlinnot

Closing this as duplicate of #2565

TimvdLippe avatar Dec 03 '17 22:12 TimvdLippe