Fix: Large iconsets rendering#79
Conversation
|
LGTM |
| this.async(function() { | ||
| // Give time for icons to be added | ||
| Polymer.RenderStatus.afterNextRender(this, () => { | ||
| this.fire('iron-iconset-added', this, {node: window}); |
There was a problem hiding this comment.
Is this a 2.x legacy version? If so, maybe use this.dispatchEvent( ... );
There was a problem hiding this comment.
Polymer team's elements are hybrid and for the most part are using this.fire. I assume in the refactor of their elements they will switch to using this.dispatchEvent(new CustomEvent())
|
@bicknellr Would you be open to this change? If you would like, I can try to figure out how to test this as well. |
|
I tried reproducing this and here's what I ended up with.
<html>
<head>
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="./other-icons.html" async>
<link rel="import" href="../../iron-icon/iron-icon.html" async>
<style>
iron-icon {
border: 1px solid gray;
width: 48px;
height: 48px;
}
</style>
</head>
<body>
<iron-icon icon="other:shape1"></iron-icon>
<iron-icon icon="other:shape10"></iron-icon>
<iron-icon icon="other:shape100"></iron-icon>
<iron-icon icon="other:shape1000"></iron-icon>
<iron-icon icon="other:shape10000"></iron-icon>
<iron-icon icon="other:shape16000"></iron-icon>
<iron-icon icon="other:shape32000"></iron-icon>
</body>
</html>
import math
import random
f = open('other-icons.html', 'w')
f.write('''
<link rel="import" href="../iron-iconset-svg.html">
<iron-iconset-svg name="other" size="48">
<svg>
<defs>
''')
for i in range(0, 2 ** 15):
f.write('<g id="shape' + str(i) + '">')
f.write('<text x="0" y="24" font-size="10">' + str(i) + '</text>')
f.write('</g>\n')
f.write('<!--')
# defeat compression w/ randomness because i'm too lazy to figure out how to disable it in polyserve...
f.write(''.join([chr(65 + math.floor(26 * random.random())) for i in range(0, 2 ** 10)]))
f.write('-->\n')
f.write('''
</defs>
</svg>
</iron-iconset-svg>
''')
f.close()(
When I go to that page, the icons up through Given that the I'm surprised that the proposed fix here doesn't seem to work in my situation. I suppose rendering incomplete pages is part of the way initial loads work and that might be why Assuming your imports are set up like this example, removing the Just out of curiosity, how large are the icon sets / bundles we're talking about? |
|
I was having the issue with I wonder if the double |
|
@generictjohnson, are you also using the |
|
IIRC, I was not using the |
|
@bicknellr Thank you for taking time to help debug this issue. I'm going to close this PR as it doesn't seem to be a proper fix for it. Does seem possibly related to |
|
I'm also seeing this issue, and am not using Both the fix in this PR (#79) and #77 solve the issue for me. |
Fixes #66
When just using
this.asyncwith a large import tree,this._createIconMap()returns an empty object.When using
Polymer.RenderStatus.afterNextRender,this._createIconMap()returns the expected icons.This feels like a better solution than waiting for the entire
document#DOMContentLoadedevent suggested in #77Will add tests and update changelog after some more testing and initial feedback.