Skip to content

Commit

Permalink
Merge pull request #51 from LottieFiles/fix/default-to-undefined-gene…
Browse files Browse the repository at this point in the history
…rator-for-parsed-lotties

Fix: default to undefined generator for parsed lotties
  • Loading branch information
jawish authored Jul 10, 2024
2 parents 68db6ea + f450904 commit a1bc6c5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/bright-eggs-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lottiefiles/lottie-js': patch
---

**metadata**: set empty array for files with no keywords
5 changes: 5 additions & 0 deletions .changeset/poor-lizards-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lottiefiles/lottie-js': patch
---

**metadata**: do not use the default generator when a file does not have metadata
3 changes: 3 additions & 0 deletions src/animation/animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ export class Animation {

if ('meta' in json) {
this.meta.fromJSON(json.meta);
} else {
this.meta.fromJSON({});
this.meta.generator = undefined;
}

if ('fonts' in json) {
Expand Down
2 changes: 1 addition & 1 deletion src/animation/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class Meta {
*/
public fromJSON(json: Record<string, any>): Meta {
this.author = json.a;
this.keywords = 'k' in json ? json.k.split(',').map((w: string) => w.trim()) : [json.k];
this.keywords = 'k' in json ? json.k.split(',').map((w: string) => w.trim()) : [];
this.generator = json.g;
this.description = json.d;
this.themeColor = json.tc;
Expand Down

0 comments on commit a1bc6c5

Please sign in to comment.