Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some fixes #44

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/channel-slider/channel-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,12 @@ export default class ChannelSlider extends NudeElement {
defaultValue: {
type: Number,
default () {
return this.defaultColor.get(this.channel);
try {
return this.defaultColor.get(this.channel);
}
catch {
return this.defaultColor.coords[0];
}
},
reflect: {
from: "value",
Expand Down
4 changes: 4 additions & 0 deletions src/color-picker/color-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ const Self = class ColorPicker extends NudeElement {
this._el.sliders.insertAdjacentHTML("beforeend", `<channel-slider space="${ this.space.id }" channel="${ channel }"></channel-slider>`);
}
}

if (change.oldInternalValue || change.oldAttributeValue) {
this.render();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? A comment would be helpful here!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we first come here on component initialization, there is no need to call render() since it'll be rendered automatically after it's connected. So, we only need to re-render the component when space actually changes after the component is mounted.

There were no issues when I called render() without any condition, but I thought I could optimize it a bit by not re-rendering the component when there is no need.

}
}

if (name === "color") {
Expand Down