Skip to content

fix(#762): ensure react is mounted in Jquery3 #867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gemfiles/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
BUNDLE_RETRY: "1"
15 changes: 2 additions & 13 deletions lib/assets/javascripts/react_ujs.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,7 @@ module.exports = function(ujs) {
nativeEvents.teardown(ujs);
}

if (ujs.jQuery) {
ujs.handleEvent = function(eventName, callback) {
ujs.jQuery(document).on(eventName, callback);
};
ujs.removeEvent = function(eventName, callback) {
ujs.jQuery(document).off(eventName, callback);
}
} else if ('addEventListener' in window) {
if ('addEventListener' in window) {
ujs.handleEvent = function(eventName, callback) {
document.addEventListener(eventName, callback);
};
Expand Down Expand Up @@ -387,10 +380,7 @@ module.exports = {
// Attach handlers to browser events to mount
// (There are no unmount handlers since the page is destroyed on navigation)
setup: function(ujs) {
if (ujs.jQuery) {
// Use jQuery if it's present:
ujs.handleEvent("ready", ujs.handleMount);
} else if ('addEventListener' in window) {
if ('addEventListener' in window) {
ujs.handleEvent('DOMContentLoaded', ujs.handleMount);
} else {
// add support to IE8 without jQuery
Expand All @@ -399,7 +389,6 @@ module.exports = {
},

teardown: function(ujs) {
ujs.removeEvent("ready", ujs.handleMount);
ujs.removeEvent('DOMContentLoaded', ujs.handleMount);
ujs.removeEvent('onload', ujs.handleMount);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"webpack": "^2.3.3"
},
"dependencies": {
"react_ujs": "^2.4.2"
"react_ujs": "^2.4.3"
}
}
15 changes: 2 additions & 13 deletions react_ujs/dist/react_ujs.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,7 @@ module.exports = function(ujs) {
nativeEvents.teardown(ujs);
}

if (ujs.jQuery) {
ujs.handleEvent = function(eventName, callback) {
ujs.jQuery(document).on(eventName, callback);
};
ujs.removeEvent = function(eventName, callback) {
ujs.jQuery(document).off(eventName, callback);
}
} else if ('addEventListener' in window) {
if ('addEventListener' in window) {
ujs.handleEvent = function(eventName, callback) {
document.addEventListener(eventName, callback);
};
Expand Down Expand Up @@ -387,10 +380,7 @@ module.exports = {
// Attach handlers to browser events to mount
// (There are no unmount handlers since the page is destroyed on navigation)
setup: function(ujs) {
if (ujs.jQuery) {
// Use jQuery if it's present:
ujs.handleEvent("ready", ujs.handleMount);
} else if ('addEventListener' in window) {
if ('addEventListener' in window) {
ujs.handleEvent('DOMContentLoaded', ujs.handleMount);
} else {
// add support to IE8 without jQuery
Expand All @@ -399,7 +389,6 @@ module.exports = {
},

teardown: function(ujs) {
ujs.removeEvent("ready", ujs.handleMount);
ujs.removeEvent('DOMContentLoaded', ujs.handleMount);
ujs.removeEvent('onload', ujs.handleMount);
}
Expand Down
9 changes: 1 addition & 8 deletions react_ujs/src/events/detect.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@ module.exports = function(ujs) {
nativeEvents.teardown(ujs);
}

if (ujs.jQuery) {
ujs.handleEvent = function(eventName, callback) {
ujs.jQuery(document).on(eventName, callback);
};
ujs.removeEvent = function(eventName, callback) {
ujs.jQuery(document).off(eventName, callback);
}
} else if ('addEventListener' in window) {
if ('addEventListener' in window) {
ujs.handleEvent = function(eventName, callback) {
document.addEventListener(eventName, callback);
};
Expand Down
6 changes: 1 addition & 5 deletions react_ujs/src/events/native.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ module.exports = {
// Attach handlers to browser events to mount
// (There are no unmount handlers since the page is destroyed on navigation)
setup: function(ujs) {
if (ujs.jQuery) {
// Use jQuery if it's present:
ujs.handleEvent("ready", ujs.handleMount);
} else if ('addEventListener' in window) {
if ('addEventListener' in window) {
ujs.handleEvent('DOMContentLoaded', ujs.handleMount);
} else {
// add support to IE8 without jQuery
Expand All @@ -14,7 +11,6 @@ module.exports = {
},

teardown: function(ujs) {
ujs.removeEvent("ready", ujs.handleMount);
ujs.removeEvent('DOMContentLoaded', ujs.handleMount);
ujs.removeEvent('onload', ujs.handleMount);
}
Expand Down
Loading