Skip to content

Commit

Permalink
The TextStyle.setStyle method will no longer mutate the given `styl…
Browse files Browse the repository at this point in the history
…e` object if it includes a numeric `fontSize` value. Fix #6863
  • Loading branch information
photonstorm committed Jul 15, 2024
1 parent b14c580 commit 5038c26
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/gameobjects/text/TextStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,6 @@ var TextStyle = new Class({
if (updateText === undefined) { updateText = true; }
if (setDefaults === undefined) { setDefaults = false; }

// Avoid type mutation
// eslint-disable-next-line no-prototype-builtins
if (style && style.hasOwnProperty('fontSize') && typeof style.fontSize === 'number')
{
style.fontSize = style.fontSize.toString() + 'px';
}

for (var key in propertyMap)
{
var value = (setDefaults) ? propertyMap[key][1] : this[key];
Expand All @@ -402,6 +395,10 @@ var TextStyle = new Class({
// Callback & scope should be set without processing the values
this[key] = GetValue(style, propertyMap[key][0], value);
}
else if (key === 'fontSize' && typeof style.fontSize === 'number')
{
this[key] = style.fontSize.toString() + 'px';
}
else
{
this[key] = GetAdvancedValue(style, propertyMap[key][0], value);
Expand Down

0 comments on commit 5038c26

Please sign in to comment.