Polymer / polymer

Our original Web Component library.
https://polymer-library.polymer-project.org/
BSD 3-Clause "New" or "Revised" License
22.05k stars 2.01k forks source link

'_showHideChildren is not a function' thrown with dom-repeat and dom-if #4096

Open nik3daz opened 7 years ago

nik3daz commented 7 years ago

Description

Having certain dom-repeat and dom-if structures causes Uncaught TypeError: this._instances[i]._showHideChildren is not a function on new data sometimes.

Live Demo

https://jsbin.com/lehajuvito/1/edit?html,console,output

Steps to Reproduce

  1. Go to JSBin
  2. Mash the Refresh button
  3. Error pops into the console occasionally

    Expected Results

_showHideChildren should not be called when the instance is a placeholder.

Actual Results

It does get called, but it doesn't exist, throwing an error.

Versions

web-padawan commented 7 years ago

Seems that you are missing using as which is required for nested dom-repeat. Have a look how this should look like: https://jsbin.com/meqogakice/edit?html,console,output

nik3daz commented 7 years ago

It seems to work both ways for me (on Chrome). Either way, the error still appears when you hit refresh a few times.

kevinpschaaf commented 7 years ago

Resolved by https://github.com/Polymer/polymer/pull/4097

arthurevans commented 7 years ago

Running the original JSBin against 1.7.1, I'm not seeing the original error message, but I am seeing this new console error appear occasionally instead:

"Error: The ref_node to be inserted before is not a child of this node
    at DomApi.insertBefore (https://polygit.org/components/polymer/polymer-mini.html:709:7)
    at HTMLTemplateElement._insertInstance (https://polygit.org/components/polymer/polymer.html:5042:25)
    at HTMLTemplateElement._render  
    ...
web-padawan commented 7 years ago

Any update on this? Occasionally faced this issue as well in a rarely reproducible case.

chen-ye commented 4 years ago

I can reliably reproduce this with the following test-case: https://jsfiddle.net/Lq2mczh6/

Specific parameters to trigger this bug:

  1. Child dom-repeat is nested inside a dom-if (doesn't matter if the 'if' is always true).
  2. Child dom-repeat is configured with initial-count = x
  3. items is set to an 2d array where the size of the outer array is n, and the size of the inner array is m != x.
  4. Page is rendered/flushed.
  5. items is set to a 2d array where the size of the outer array < n (in this case, empty).

It doesn't seem I can get this to reproduce without using initial-count

stale[bot] commented 3 years ago

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.