Skip to content

Commit 40dfff8

Browse files
author
AleBles
committedJul 28, 2016
Fixed an issue where setText would crash if no placeholder was defined
1 parent 9e560d2 commit 40dfff8

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed
 

‎build/phaser-input.js

+7-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎build/phaser-input.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎build/phaser-input.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎example/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { create: create, preload: preload}, true);
3030
var figure;
3131
var testHolder;
32+
var password;
3233
Phaser.Device.whenReady(function () {
3334
game.plugins.add(Fabrique.Plugins.InputField);
3435
game.plugins.add(Fabrique.Plugins.NineSlice);
@@ -80,7 +81,7 @@
8081
//We'd need a password too
8182
var passBg = game.add.nineSlice(game.width / 2+ 5, 250, 'input', 200, 50);
8283
passBg.anchor.set(0.5);
83-
var password = game.add.inputField(game.width / 2 - 85, 250 - 17, {
84+
password = game.add.inputField(game.width / 2 - 85, 250 - 17, {
8485
font: '18px Arial',
8586
fill: '#212121',
8687
fillAlpha: 0,

‎ts/InputField.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,12 @@ module Fabrique {
483483
}
484484

485485
public setText(text: string = ''): void {
486-
if (text.length > 0) {
487-
this.placeHolder.visible = false;
488-
} else {
489-
this.placeHolder.visible = true;
486+
if (null !== this.placeHolder) {
487+
if (text.length > 0) {
488+
this.placeHolder.visible = false;
489+
} else {
490+
this.placeHolder.visible = true;
491+
}
490492
}
491493

492494
this.value = text;

0 commit comments

Comments
 (0)
Please sign in to comment.