_shouldPropChange and object/array change notifications

13 views
Skip to first unread message

eha...@gmail.com

unread,
Dec 7, 2016, 6:43:58 PM12/7/16
to Polymer
I think that changes for properties of type object/array should not be notified when you reset from null to null. Is this correct??

I am trying to migrate the vaadin date time picker to use Polymer 2.0-preview and was getting a very weird behavior, I've been all afternoon trying to pinpoint the problem and the only thing I can say is that I believe is related to two way binding marking the selectedDate as changed when nothing had changed.

Code from https://github.com/Polymer/polymer/blob/2.0-preview/src/properties/property-accessors.html, I added the code in yellow and now it works, am I missing something?

      _shouldPropChange(property, value, old) {
        return (
          // Strict equality check for primitives
          (old !== value && 
           // This ensures old:NaN, value:NaN always returns false
           (old === old || value === value)) ||
          // Objects/Arrays always pass
          (typeof value == 'object' && !(old === value && value === null)) //don't notify when changing from null to null
        );

I'd really appreciate if anyone can clarify on this.

Thank you,

Erich von Hauske
Reply all
Reply to author
Forward
0 new messages