@lightningtv/core
Advanced tools
Comparing version 2.2.3 to 2.2.4
@@ -442,17 +442,33 @@ import { renderer, createShader } from './lightningInit.js'; | ||
if (this._undoStyles || (this.style && keyExists(this.style, states))) { | ||
this._undoStyles = this._undoStyles || []; | ||
const stylesToUndo = {}; | ||
this._undoStyles.forEach((styleKey) => { | ||
stylesToUndo[styleKey] = this.style[styleKey]; | ||
}); | ||
const newStyles = states.reduce((acc, state) => { | ||
const styles = this.style[state]; | ||
if (styles) { | ||
acc = { | ||
...acc, | ||
...styles, | ||
}; | ||
} | ||
return acc; | ||
}, {}); | ||
let stylesToUndo; | ||
if (this._undoStyles && this._undoStyles.length) { | ||
stylesToUndo = {}; | ||
this._undoStyles.forEach((styleKey) => { | ||
if (isDev) { | ||
if (this.style[styleKey] === undefined) { | ||
console.warn('fallback style key not found: ', styleKey); | ||
} | ||
} | ||
stylesToUndo[styleKey] = this.style[styleKey]; | ||
}); | ||
} | ||
const numStates = states.length; | ||
if (numStates === 0) { | ||
Object.assign(this, stylesToUndo); | ||
this._undoStyles = []; | ||
return; | ||
} | ||
let newStyles; | ||
if (numStates === 1) { | ||
newStyles = this.style[states[0]]; | ||
newStyles = stylesToUndo | ||
? { ...stylesToUndo, ...newStyles } | ||
: newStyles; | ||
} | ||
else { | ||
newStyles = states.reduce((acc, state) => { | ||
const styles = this.style[state]; | ||
return styles ? { ...acc, ...styles } : acc; | ||
}, stylesToUndo || {}); | ||
} | ||
this._undoStyles = Object.keys(newStyles); | ||
@@ -464,3 +480,3 @@ // Apply transition first | ||
// Apply the styles | ||
Object.assign(this, stylesToUndo, newStyles); | ||
Object.assign(this, newStyles); | ||
} | ||
@@ -467,0 +483,0 @@ } |
{ | ||
"name": "@lightningtv/core", | ||
"version": "2.2.3", | ||
"version": "2.2.4", | ||
"description": "Lightning TV Core for Universal Renderers", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -663,19 +663,34 @@ import { renderer, createShader } from './lightningInit.js'; | ||
if (this._undoStyles || (this.style && keyExists(this.style, states))) { | ||
this._undoStyles = this._undoStyles || []; | ||
const stylesToUndo: { [key: string]: any } = {}; | ||
let stylesToUndo: { [key: string]: any } | undefined; | ||
if (this._undoStyles && this._undoStyles.length) { | ||
stylesToUndo = {}; | ||
this._undoStyles.forEach((styleKey) => { | ||
if (isDev) { | ||
if (this.style[styleKey] === undefined) { | ||
console.warn('fallback style key not found: ', styleKey); | ||
} | ||
} | ||
stylesToUndo![styleKey] = this.style[styleKey]; | ||
}); | ||
} | ||
this._undoStyles.forEach((styleKey) => { | ||
stylesToUndo[styleKey] = this.style[styleKey]; | ||
}); | ||
const numStates = states.length; | ||
if (numStates === 0) { | ||
Object.assign(this, stylesToUndo); | ||
this._undoStyles = []; | ||
return; | ||
} | ||
const newStyles: Styles = states.reduce((acc, state) => { | ||
const styles = this.style[state]; | ||
if (styles) { | ||
acc = { | ||
...acc, | ||
...styles, | ||
}; | ||
} | ||
return acc; | ||
}, {}); | ||
let newStyles: Styles; | ||
if (numStates === 1) { | ||
newStyles = this.style![states[0] as keyof Styles] as Styles; | ||
newStyles = stylesToUndo | ||
? { ...stylesToUndo, ...newStyles } | ||
: newStyles; | ||
} else { | ||
newStyles = states.reduce((acc, state) => { | ||
const styles = this.style![state]; | ||
return styles ? { ...acc, ...styles } : acc; | ||
}, stylesToUndo || {}); | ||
} | ||
@@ -690,3 +705,3 @@ this._undoStyles = Object.keys(newStyles); | ||
// Apply the styles | ||
Object.assign(this, stylesToUndo, newStyles); | ||
Object.assign(this, newStyles); | ||
} | ||
@@ -693,0 +708,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
218294
3320