Cannot read property 'parentNode' of null error in Polymer 2
See original GitHub issueHi Nathan, thank you for the great tool which works pretty good in HTML files. However when I tried it in a Polymer 2 element I mocked-up, I couldn’t get it work and keep encountering the error of Cannot read property 'parentNode' of null
.
I tried to put code
Split(['#column-tag-list', '#column-repo-list', '#column-repo-page'], {
sizes: [25,25,50],
minSize: [300, 300, 960],
gutterSize: 5
});
anywhere but the parentNode of null
keeps showing up.
I guess it’s due to Split()
could not find the nodes neither their parent before the shadow DOM are ready, therefore, I put the Split([])
code in the ready(){}
method of the definition class as the following, it didn’t work neither.
Please help on how to use it in Polymer 2 properly. Thanks!
<dom-module id="pol-app">
<template>
<style>
...
</style>
<div class="app-container">
<div id="column-tag-list" class="column">
...
</div>
<div id="column-repo-list" class="column">
...
</div>
<div id="column-repo-page" class="column">
...
</div>
</div>
</template>
<script src="../../bower_components/Split.js/split.min.js"></script>
<script>
class PolApp extends Polymer.Element {
static get is() { return 'pol-app'; }
static get properties() {
return {
...
};
}
...
constructor() {
super();
this.rootPattern = (new URL(this.rootPath)).pathname;
}
ready() {
console.log('Hi Split.');
Split(['#column-tag-list', '#column-repo-list', '#column-repo-page'], {
sizes: [25,25,50],
minSize: [300, 300, 960],
gutterSize: 5
});
}
...
}
window.customElements.define(PolApp.is, PolApp);
</script>
</dom-module>
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Cannot read property 'parentNode' of null error in Polymer 2 #86
Hi, which version of Split.js are you using? The error sounds like those elements are not being found in the document.
Read more >Javascript error: Cannot read property 'parentNode' of null
There are two possibilities: editInput is a typo, and the actual id of that element is different (ids are case-sensitive).
Read more >Sidenav has error : Cannot read property &#039;parentNod
Hi,. You have added option data-mdb-scroll-container="#scrollContainer" which points to the #scrollContainer element that is not present in your HTML.
Read more >Cannot read property 'length' of undefined in grid.$connector.
Hey there :) We're setting up a grid where the user is able to filter items which are related to brands. One filter...
Read more >"Cannot read property parentNode" error - Vue Forum
Given the mention of parentNode in the error message, my only guess would be that it is somehow related to the use of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This could work.
https://www.polymer-project.org/2.0/docs/upgrade#callback-contracts-have-changed https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/
@nathancahill I tried
window.document.querySelector('#column-tag-list')
, and it didn’t work.@skyjia
that.shadowRoot.querySelector('#column1')
works. And thesetTimeout()
is necessary when usedSplit()
in Polymer 2.Thanks, guys!