From 8e4dc1f078ee862454e45e08e176aa5c6e74fea6 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Tue, 13 Oct 2015 12:04:57 +0100 Subject: [PATCH] ScaleManager.getParentBounds now checks if `parentNode` has an `offsetParent` before calling `getBoundingClientRect` on it (thanks @McFarts #2134) --- README.md | 1 + src/core/ScaleManager.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fd07af486..928d22c12 100644 --- a/README.md +++ b/README.md @@ -307,6 +307,7 @@ can be controlled per-input mode. * The ScaleManager no longer creates a Phaser.FlexGrid if the class isn't available (i.e. excluded via a custom build) * Time.suggestedFps is now defaulted to Time.desiredFps for the first few frames until things have settled down (previously it was `null`) (thanks @noidexe #2130) * Text with anchor 0.5 and word wrap would have an extra space added to its width calculations, this is now adjusted for (thanks @nickryall #2052 #1990) +* ScaleManager.getParentBounds now checks if `parentNode` has an `offsetParent` before calling `getBoundingClientRect` on it (thanks @McFarts #2134) ### Bug Fixes diff --git a/src/core/ScaleManager.js b/src/core/ScaleManager.js index 2a72c3d7d..f29a79db9 100644 --- a/src/core/ScaleManager.js +++ b/src/core/ScaleManager.js @@ -1421,7 +1421,7 @@ Phaser.ScaleManager.prototype = { { // Ref. http://msdn.microsoft.com/en-us/library/hh781509(v=vs.85).aspx for getBoundingClientRect var clientRect = parentNode.getBoundingClientRect(); - var parentRect = parentNode.offsetParent.getBoundingClientRect(); + var parentRect = (parentNode.offsetParent) ? parentNode.offsetParent.getBoundingClientRect() : parentNode.getBoundingClientRect(); bounds.setTo(clientRect.left - parentRect.left, clientRect.top - parentRect.top, clientRect.width, clientRect.height);