Improve JS Travis testing

Summary:
Build emscripten js file on travis
Closes https://github.com/facebook/yoga/pull/397

Reviewed By: arcanis

Differential Revision: D4579563

Pulled By: emilsjolander

fbshipit-source-id: fa5f92fd26f758fb617e428c07aabf2dccd63b37
This commit is contained in:
Maël Nison
2017-02-20 05:31:20 -08:00
committed by Facebook Github Bot
parent 3f68b4f76b
commit 78ade6cfb5
23 changed files with 8934 additions and 8926 deletions

View File

@@ -107,7 +107,7 @@ module.exports = function (bind, lib) {
case constants.UNIT_PERCENT:
return `${this.value}%`;
case constants.UNIT_AUTO:
return `auto`;
@@ -129,20 +129,22 @@ module.exports = function (bind, lib) {
for (let fnName of [ `setPosition`, `setMargin`, `setFlexBasis`, `setWidth`, `setHeight`, `setMinWidth`, `setMinHeight`, `setMaxWidth`, `setMaxHeight`, `setPadding` ]) {
let methods = { [constants.UNIT_POINT]: lib.Node.prototype[fnName], [constants.UNIT_PERCENT]: lib.Node.prototype[`${fnName}Percent`] };
if (Object.keys(methods).some(method => methods[method] == null))
throw new Error(`Assertion failed; some unit derivates of ${fnName} seem missing`);
let methods = { [constants.UNIT_POINT]: lib.Node.prototype[fnName], [constants.UNIT_PERCENT]: lib.Node.prototype[`${fnName}Percent`], [constants.UNIT_AUTO]: lib.Node.prototype[`${fnName}Auto`] };
patch(lib.Node.prototype, fnName, function (original, ... args) {
// We patch all these functions to add support for the following calls:
// .setWidth(100) / .setWidth("100%") / .setWidth(.getWidth())
// .setWidth(100) / .setWidth("100%") / .setWidth(.getWidth()) / .setWidth("auto")
let value = args.pop();
let unit, asNumber;
if (value instanceof Value) {
if (value === `auto`) {
unit = constants.UNIT_AUTO;
asNumber = undefined;
} else if (value instanceof Value) {
unit = value.unit;
asNumber = value.valueOf();
@@ -154,7 +156,14 @@ module.exports = function (bind, lib) {
}
return methods[unit].call(this, ... args, asNumber);
if (!Object.prototype.hasOwnProperty.call(methods, unit))
throw new Error(`Failed to execute "${fnName}": Unsupported unit.`);
if (asNumber !== undefined) {
return methods[unit].call(this, ... args, asNumber);
} else {
return methods[unit].call(this, ... args);
}
});