From 9a0b6c24a4d8e8b1b0e000302f130bb134421453 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Thu, 6 Aug 2015 10:28:49 +0100 Subject: [PATCH] Text can now accept `undefined` or `null` as the `text` argument in the constructor and will cast it as an empty string. --- README.md | 1 + src/gameobjects/Text.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cfe5691f2..31cff8622 100644 --- a/README.md +++ b/README.md @@ -262,6 +262,7 @@ If you are an exceptional JavaScript developer and would like to join the Phaser * TypeScript definitions fixes and updates (thanks @clark-stevenson @vrecluse) * JSDoc typo fixes (thanks ) * VideoStream.active = false is used if the browser supports it, otherwise it falls back to VideoStream.stop. +* Text can now accept `undefined` or `null` as the `text` argument in the constructor and will cast it as an empty string. ### Bug Fixes diff --git a/src/gameobjects/Text.js b/src/gameobjects/Text.js index a55db2c57..6c56a98d6 100644 --- a/src/gameobjects/Text.js +++ b/src/gameobjects/Text.js @@ -40,7 +40,16 @@ Phaser.Text = function (game, x, y, text, style) { x = x || 0; y = y || 0; - text = text.toString() || ''; + + if (text === undefined || text === null) + { + text = ''; + } + else + { + text = text.toString(); + } + style = style || {}; /**