Skip to content

Commit

Permalink
Remove what is not needed, export fresh version to fix #2
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Jul 13, 2014
1 parent 770f334 commit 6d66c19
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 23 deletions.
29 changes: 8 additions & 21 deletions hot.js
@@ -1,28 +1,11 @@
'use strict';

var _ = require('underscore');
var setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {
/* jshint proto:true */
obj.__proto__ = proto;
return obj;
};

var coalesce = (function () {
var queue = [],
processQueue;

processQueue = _.debounce(function () {
while (queue.length) {
queue.pop().call();
}
}, 0);

return function(f) {
queue.push(f);
processQueue();
};
})();

module.exports = function (React) {
var mounted = [];

Expand All @@ -42,15 +25,19 @@ module.exports = function (React) {
spec.mixins.push(Mixin);
return React.createClass(spec);
},

updateClass: function (spec) {
var freshProto = React.createClass(spec).componentConstructor.prototype;
var Component = React.createClass(spec);
var newProto = Component.componentConstructor.prototype;

mounted.forEach(function (instance) {
setPrototypeOf(instance, freshProto);
instance.constructor.prototype = freshProto;
setPrototypeOf(instance, newProto);
instance.constructor.prototype = newProto;
instance._bindAutoBindMethods();
coalesce(instance.forceUpdate);
instance.forceUpdate();
});

return Component;
}
};
};
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -9,7 +9,7 @@ module.exports.pitch = function (remainingRequest) {
'module.exports = require(' + JSON.stringify(patchedModuleRequest) + ')(hot.createClass);',
'if (module.hot) {',
' module.hot.accept(' + JSON.stringify(patchedModuleRequest) + ', function () {',
' require(' + JSON.stringify(patchedModuleRequest) + ')(hot.updateClass);',
' module.exports = require(' + JSON.stringify(patchedModuleRequest) + ')(hot.updateClass);',
' });',
'}',
].join('\n');
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -9,7 +9,6 @@
"devDependencies": {
"jsx-loader": "^0.10.2",
"react": "^0.10.0",
"underscore": "^1.6.0",
"webpack": "^1.3.1"
},
"repository": {
Expand Down

0 comments on commit 6d66c19

Please sign in to comment.