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

Fixed: vizzu-story's unwanted changes to original slides object #55

Merged
merged 3 commits into from
Aug 23, 2023
Merged
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
20 changes: 19 additions & 1 deletion src/vizzu-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ class VizzuPlayer extends HTMLElement {
return this._slides;
}

set slides(slides) {
set slides(slidesSourceData) {
const slides = this.recursiveCopy(slidesSourceData);
let startSlide = this._getStartSlide(slides.slides.length);
if (this.hashNavigation) {
const hashSlide = this._slideFromHash(slides.slides.length);
Expand Down Expand Up @@ -220,6 +221,23 @@ class VizzuPlayer extends HTMLElement {
return this._locked;
}

recursiveCopy(obj) {
if (obj === null) return null;
const clone = Object.assign({}, obj);
Object.keys(clone).forEach(
(key) =>
(clone[key] =
typeof obj[key] === "object"
? this.recursiveCopy(obj[key])
: obj[key])
);
if (Array.isArray(obj)) {
clone.length = obj.length;
return Array.from(clone);
}
return clone;
}

releaseLock() {
this.log("release lock");
this._locked = false;
Expand Down