From 1c053303a993eee938321c1f04881966b561a0d0 Mon Sep 17 00:00:00 2001 From: LaySent Date: Sun, 22 Oct 2017 00:07:45 +0800 Subject: [PATCH 1/6] improve fix for #423 --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index ba0fe64..670891e 100644 --- a/src/index.js +++ b/src/index.js @@ -5,9 +5,9 @@ const version = '15.1.0'; // trick libraries to think we are react const ELEMENTS = 'a abbr address area article aside audio b base bdi bdo big blockquote body br button canvas caption cite code col colgroup data datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header hgroup hr html i iframe img input ins kbd keygen label legend li link main map mark menu menuitem meta meter nav noscript object ol optgroup option output p param picture pre progress q rp rt ruby s samp script section select small source span strong style sub summary sup table tbody td textarea tfoot th thead time title tr track u ul var video wbr circle clipPath defs ellipse g image line linearGradient mask path pattern polygon polyline radialGradient rect stop svg text tspan'.split(' '); -const REACT_ELEMENT_TYPE = (typeof Symbol!=='undefined' && Symbol.for && Symbol.for('react.element')) || 0xeac7; +const REACT_ELEMENT_TYPE = (typeof Symbol!=='undefined' && typeof Symbol.for === 'function' && Symbol.for('react.element')) || 0xeac7; -const COMPONENT_WRAPPER_KEY = (typeof Symbol!=='undefined' && Symbol.for) ? Symbol.for('__preactCompatWrapper') : '__preactCompatWrapper'; +const COMPONENT_WRAPPER_KEY = (typeof Symbol!=='undefined' && typeof Symbol.for === 'function') ? Symbol.for('__preactCompatWrapper') : '__preactCompatWrapper'; // don't autobind these methods since they already have guaranteed context. const AUTOBIND_BLACKLIST = { From c0a3d3a6962302e628b64668024ca0be9ad66eb7 Mon Sep 17 00:00:00 2001 From: LaySent Date: Thu, 26 Oct 2017 11:57:06 +0800 Subject: [PATCH 2/6] remove usage of .bind with additional parameter Before ECMAScript 5, libraries define .bind without additional parameter. To work with these libraries, change this specific usage of bind --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 670891e..f513e42 100644 --- a/src/index.js +++ b/src/index.js @@ -218,7 +218,7 @@ let currentComponent; function createFactory(type) { - return createElement.bind(null, type); + return (...args) => createElement(type, ...args); } From 189bbabab2d88a51fcec80db50667f98ec22f835 Mon Sep 17 00:00:00 2001 From: LaySent Date: Tue, 30 Jan 2018 10:55:57 +0800 Subject: [PATCH 3/6] use .apply to replace .bind --- src/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index f513e42..077bfac 100644 --- a/src/index.js +++ b/src/index.js @@ -218,7 +218,9 @@ let currentComponent; function createFactory(type) { - return (...args) => createElement(type, ...args); + return function () { + return createElement.apply(type, arguments); + }; } From 7ebe07400cd6f27ea4bfcdc59c6b98965394ebde Mon Sep 17 00:00:00 2001 From: LaySent Date: Tue, 30 Jan 2018 11:16:49 +0800 Subject: [PATCH 4/6] fix eslint issue (introduced by #289) --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 077bfac..dba574c 100644 --- a/src/index.js +++ b/src/index.js @@ -594,7 +594,7 @@ PureComponent.prototype.shouldComponentUpdate = function(props, state) { }; function unstable_batchedUpdates(callback) { - callback(); + callback(); } export { From 23a4231147b4446c2cfa5084f39b2c0f04145377 Mon Sep 17 00:00:00 2001 From: LaySent Date: Sat, 23 Jun 2018 10:15:11 +0800 Subject: [PATCH 5/6] Revert "use .apply to replace .bind" This reverts commit 189bbabab2d88a51fcec80db50667f98ec22f835. --- src/index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index dba574c..4e8e64d 100644 --- a/src/index.js +++ b/src/index.js @@ -218,9 +218,7 @@ let currentComponent; function createFactory(type) { - return function () { - return createElement.apply(type, arguments); - }; + return (...args) => createElement(type, ...args); } From c3ac3b5286d558a5b0d5030c9e9c7a553f30a752 Mon Sep 17 00:00:00 2001 From: LaySent Date: Sat, 23 Jun 2018 10:15:27 +0800 Subject: [PATCH 6/6] Revert "remove usage of .bind with additional parameter" This reverts commit c0a3d3a6962302e628b64668024ca0be9ad66eb7. --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 4e8e64d..795ea9b 100644 --- a/src/index.js +++ b/src/index.js @@ -218,7 +218,7 @@ let currentComponent; function createFactory(type) { - return (...args) => createElement(type, ...args); + return createElement.bind(null, type); }