mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
Fix case where lack of colour attribute results in null. (#1894)
Fixes regression in #1893. Patch on change in #1831. Verify typeof colour variable before passing through Number(). Missing attributes return null, and Number(null) === 0, resulting in a red hues category color.
This commit is contained in:
committed by
GitHub
parent
5159de83cf
commit
15817e78a1
@@ -334,10 +334,14 @@ Blockly.Toolbox.prototype.syncTrees_ = function(treeIn, treeOut, pathToMedia) {
|
||||
// (eg. `%{BKY_MATH_HUE}`).
|
||||
var colour = Blockly.utils.replaceMessageReferences(
|
||||
childIn.getAttribute('colour'));
|
||||
if (/^#[0-9a-fA-F]{6}$/.test(colour)) {
|
||||
if (colour === null || colour === '') {
|
||||
// No attribute. No colour.
|
||||
childOut.hexColour = '';
|
||||
} else if (/^#[0-9a-fA-F]{6}$/.test(colour)) {
|
||||
childOut.hexColour = colour;
|
||||
this.hasColours_ = true;
|
||||
} else if (!isNaN(Number(colour))) {
|
||||
} else if (typeof colour === 'number'
|
||||
|| (typeof colour === 'string' && !isNaN(Number(colour)))) {
|
||||
childOut.hexColour = Blockly.hueToRgb(Number(colour));
|
||||
this.hasColours_ = true;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user