Skip to content

Commit

Permalink
Allows setting metal compatibility mode via a global variable - Fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
mairatma committed Sep 21, 2016
1 parent b495e94 commit 7d818c0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/metal/src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ class core {
* @return {Object}
*/
static getCompatibilityModeData() {
// Compatibility mode can be set via the __METAL_COMPATIBILITY__ global var.
if (!compatibilityModeData_) {
if (typeof window !== 'undefined' && window.__METAL_COMPATIBILITY__) {
core.enableCompatibilityMode(window.__METAL_COMPATIBILITY__);
}
}
return compatibilityModeData_;
}

Expand Down
11 changes: 11 additions & 0 deletions packages/metal/test/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ describe('core', function() {
});

describe('Compatibility Mode', function() {
afterEach(function() {
delete window.__METAL_COMPATIBILITY__;
core.disableCompatibilityMode();
});

it('should return no data if compatibility mode is not enabled', function() {
assert.ok(!core.getCompatibilityModeData());
});
Expand All @@ -277,6 +282,12 @@ describe('core', function() {
assert.strictEqual(data, core.getCompatibilityModeData());
});

it('should return the data specified by global var', function() {
const data = {};
window.__METAL_COMPATIBILITY__ = data;
assert.strictEqual(data, core.getCompatibilityModeData());
});

it('should return no data if compatibility mode is disabled', function() {
const data = {};
core.enableCompatibilityMode(data);
Expand Down

0 comments on commit 7d818c0

Please sign in to comment.