Skip to content

Commit

Permalink
1.0.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
JayCanuck committed Mar 26, 2018
2 parents 9d0746b + 1f19c66 commit a2d788a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.0.1 (March 26, 2018)

* SnapshotPlugin's mock window updated to catch modular event listeners added to document/window and forwarded at launch-time. Fixes React 16 support.
* SnapshotPlugin will now output a helpful stack trace on exception.

## 1.0.0 (March 13, 2018)

* Added basic documentation.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@enact/dev-utils",
"version": "1.0.0",
"version": "1.0.1",
"description": "A collection of development utilities for Enact apps.",
"main": "index.js",
"author": "Jason Robitaille <jason.robitaille@lge.com>",
Expand Down
1 change: 1 addition & 0 deletions plugins/SnapshotPlugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function SnapshotPlugin(options) {
this.options.args = this.options.args || [
'--profile-deserialization',
'--random-seed=314159265',
'--abort_on_uncaught_exception',
'--startup-blob=snapshot_blob.bin'
];
if (process.env.V8_SNAPSHOT_ARGS) {
Expand Down
24 changes: 20 additions & 4 deletions plugins/SnapshotPlugin/mock-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@
* A helper utility meant to simulate a basic window object for ReactDOM usage during snapshot execution.
*/

var orig = {}, nop = function() {};
var orig = {}, listeners = [], nop = function() {};
var mock = {
CompositionEvent: nop,
TextEvent: nop,
addEventListener: function() {
listeners.push({args: Array.prototype.slice.call(arguments)});
},
document: {
addEventListener: nop,
addEventListener: function() {
listeners.push({doc: true, args: Array.prototype.slice.call(arguments)});
},
createElement: function() {
return {style:{}};
return {style: {}};
},
documentElement: {
textContent: '',
Expand All @@ -34,7 +39,7 @@ var mock = {
}
},
location: {
protocol:'http:'
protocol: 'http:'
},
navigator: {
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36'
Expand Down Expand Up @@ -65,5 +70,16 @@ module.exports = {
delete global[x];
}
}
},
attachListeners: function(realWindow) {
if (realWindow) {
for (var i = 0; i < listeners.length; i++) {
if (listeners[i].doc) {
realWindow.document.addEventListener.apply(null, listeners[i].args);
} else {
realWindow.addEventListener.apply(null, listeners[i].args);
}
}
}
}
};
3 changes: 2 additions & 1 deletion plugins/SnapshotPlugin/snapshot-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ global.updateEnvironment = function() {
ExecutionEnvironment.canUseEventListeners = canUseDOM && !!(window.addEventListener || window.attachEvent);
ExecutionEnvironment.canUseViewport = canUseDOM && !!window.screen;
ExecutionEnvironment.isInWorker = !canUseDOM; // For now, this is true - might change in the future.
mockWindow.attachListeners(ExecutionEnvironment.canUseEventListeners && window)

try {
// Mark the iLib localestorage cache as needing re-validation.
Expand Down Expand Up @@ -52,7 +53,7 @@ global.updateEnvironment = function() {
};

if(typeof window == 'undefined'
&& (typeof process === 'undefined' || !process.versions || !process.versions.node)) {
&& (!global.process || !global.process.versions || !global.process.versions.node)) {
mockWindow.activate();
ExecutionEnvironment.canUseDOM = true;
ExecutionEnvironment.canUseWorkers = false;
Expand Down

0 comments on commit a2d788a

Please sign in to comment.