From 263c45b919bbd3c028ff75acc89853681b16ea89 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Fri, 4 Dec 2015 12:12:19 -0500 Subject: [PATCH] Make babelHelpers.inherits even more robust against PhantomJS bugs. --- packages/babel-runtime/babel-runtime.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/babel-runtime/babel-runtime.js b/packages/babel-runtime/babel-runtime.js index cdbcad231f..cafe137ee1 100644 --- a/packages/babel-runtime/babel-runtime.js +++ b/packages/babel-runtime/babel-runtime.js @@ -117,21 +117,21 @@ babelHelpers = { // using babel-runtime is almost certainly using it because of the // ecmascript package, which also implies ecmascript-runtime. Object.getOwnPropertyNames(superClass).forEach(function (k) { - if (Object.getOwnPropertyDescriptor(subClass, k)) { - // If subClass already has a property by this name, then it - // would not be inherited, so it should not be copied. This - // notably excludes properties like .prototype and .name. - return; - } - // This property descriptor dance preserves getter/setter behavior // in browsers that support accessor properties (all except // IE8). In IE8, the superClass can't have accessor properties // anyway, so this code is still safe. - Object.defineProperty( - subClass, k, - Object.getOwnPropertyDescriptor(superClass, k) - ); + var descriptor = Object.getOwnPropertyDescriptor(superClass, k); + if (descriptor && typeof descriptor === "object") { + if (Object.getOwnPropertyDescriptor(subClass, k)) { + // If subClass already has a property by this name, then it + // would not be inherited, so it should not be copied. This + // notably excludes properties like .prototype and .name. + return; + } + + Object.defineProperty(subClass, k, descriptor); + } }); } },