Skip to content

Commit

Permalink
fix: fix addStyleShadow when same style object is inserted multiple t…
Browse files Browse the repository at this point in the history
…imes
  • Loading branch information
yyx990803 committed Jul 17, 2018
1 parent aaba166 commit 12846a6
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions lib/addStylesShadow.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,11 @@ function addStyles (styles /* Array<StyleObject> */, shadowRoot) {
for (var i = 0; i < styles.length; i++) {
var item = styles[i]
var style = injectedStyles[item.id]
if (style) {
style.refs++
for (var j = 0; j < style.parts.length; j++) {
style.parts[j](item.parts[j])
}
for (; j < item.parts.length; j++) {
style.parts.push(addStyle(item.parts[j], shadowRoot))
}
if (style.parts.length > item.parts.length) {
style.parts.length = item.parts.length
}
} else {
var parts = []
if (!style) {

This comment has been minimized.

Copy link
@alancnet

alancnet Jul 8, 2019

@yyx990803 Evan, this seems to break Hot Module Reload. When I update a style, the following code is skipped. How do you think we should handle this?

for (var j = 0; j < item.parts.length; j++) {
parts.push(addStyle(item.parts[j], shadowRoot))
addStyle(item.parts[j], shadowRoot)
}
injectedStyles[item.id] = { id: item.id, refs: 1, parts: parts }
injectedStyles[item.id] = true
}
}
}
Expand Down

0 comments on commit 12846a6

Please sign in to comment.