Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Drop jQuery support #35

Closed
wants to merge 1 commit into from

4 participants

@mattrobenolt

In my opinion, this is too opinionated for something like TraceKit. TraceKit is a great library that provides functionality for other ligher levels libs to utilize.

With my recent commit of TraceKit.wrap(), that kind of paves the way for others to use it in a way to wrap anything they want. In the case for us (raven-js), I'm going to be providing a bunch of plugins to patch common libs that a user can pick and choose from. I'd rather not include source for jQuery for someone who isn't using jQuery.

I hope this makes sense. If anything, document the code that was removed and include it as a separate file so it still exists, but isn't so tightly coupled.

@mattrobenolt mattrobenolt Drop jQuery support
In my opinion, this is too opinionated for something like TraceKit. TraceKit is a great library that provides functionality for other ligher levels libs to utilize.

With my recent commit of TraceKit.wrap(), that kind of paves the way for others to use it in a way to wrap anything they want. In the case for us (raven-js), I'm going to be providing a bunch of plugins to patch common libs that a user can pick and choose from. I'd rather not include source for jQuery for someone who isn't using jQuery.

I hope this makes sense. If anything, document the code that was removed and include it as a separate file so it still exists, but isn't so tightly coupled.
487354f
@devinrhode2

In addition to intercepting setInterval/setTimeout, I think we should try intercepting all browser api's that accept a callback - event handlers, XMLHttpRequest .. and others I'm probably forgetting. I can't foresee any issues with this, so it's probably worth a shot

@mattrobenolt

@devinrhode2, I completely agree. I think that if we're going to automatically patch things, we should only patch native Javascript stuff. We can leave library patches for a plugin or something of that sort.

@devinrhode2

My hope is that we can intercept all browser api's so that we don't have to patch libraries. I think it would be ok to stall this PR until we get something on that front, but I completely agree we should have no (or very little) code related specifically to jQuery. Maybe at most the library could by default hookup a window.$ if it's defined, maybe not.

@mattrobenolt

Sounds fair to me. I think that should be the goal. TraceKit, by default, can/should patch native code. Let's leave the external libraries out of it. :)

@occ
Owner
occ commented

For both #35 and #38,

After discussing this in more detail- I think that we should drop jQuery support (along with setTimeout/setInterval wrappers). IMO, All of these rather magical wrappers should actually be extracted out as plugins. This also simplifies the development as we wont't need to track a third party library.

The only remaining concern is functionality change. Essentially, this is a breaking change.
Since we don't (yet) have versions, we can't tell people that the code in master doesn't act the same way as it used to.

I'll tag this one as v0.1 and go on from there.

@occ occ referenced this pull request from a commit
@occ Merge #35
Remove jQuery support and update .gitignore
0d39401
@occ
Owner
occ commented

Merged in 0d39401

@occ occ closed this
@russelldavis

Was this functionality moved to a plugin somewhere?

@devinrhode2
@devinrhode2
@edmund-huber edmund-huber referenced this pull request from a commit in fastly/TraceKit
@edmund-huber edmund-huber Revert "Merge #35"
This reverts commit 0d39401.

Having jQuery's ajax handlers automatically wrapped is useful and should not
have been removed from the library without an alternative (the plugins system
they mention but did not implement).

Conflicts:

	.gitignore
6344395
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 13, 2013
  1. @mattrobenolt

    Drop jQuery support

    mattrobenolt authored
    In my opinion, this is too opinionated for something like TraceKit. TraceKit is a great library that provides functionality for other ligher levels libs to utilize.
    
    With my recent commit of TraceKit.wrap(), that kind of paves the way for others to use it in a way to wrap anything they want. In the case for us (raven-js), I'm going to be providing a bunch of plugins to patch common libs that a user can pick and choose from. I'd rather not include source for jQuery for someone who isn't using jQuery.
    
    I hope this makes sense. If anything, document the code that was removed and include it as a separate file so it still exists, but isn't so tightly coupled.
This page is out of date. Refresh to see the latest.
Showing with 0 additions and 112 deletions.
  1. +0 −112 tracekit.js
View
112 tracekit.js
@@ -1064,118 +1064,6 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
_helper('setInterval');
}(window));
-/**
- * Extended support for backtraces and global error handling for most
- * asynchronous jQuery functions.
- */
-(function traceKitAsyncForjQuery($) {
-
- // quit if jQuery isn't on the page
- if (!$) {
- return;
- }
-
- var _oldEventAdd = $.event.add;
- $.event.add = function traceKitEventAdd(elem, types, handler, data, selector) {
- var _handler;
-
- if (handler.handler) {
- _handler = handler.handler;
- handler.handler = function traceKitHandler() {
- try {
- return _handler.apply(this, arguments);
- } catch (e) {
- TraceKit.report(e);
- throw e;
- }
- };
- } else {
- _handler = handler;
- handler = function apply_handler() {
- try {
- return _handler.apply(this, arguments);
- } catch (e) {
- TraceKit.report(e);
- throw e;
- }
- };
- }
-
- // If the handler we are attaching doesn’t have the same guid as
- // the original, it will never be removed when someone tries to
- // unbind the original function later. Technically as a result of
- // this our guids are no longer globally unique, but whatever, that
- // never hurt anybody RIGHT?!
- if (_handler.guid) {
- handler.guid = _handler.guid;
- } else {
- handler.guid = _handler.guid = $.guid++;
- }
-
- return _oldEventAdd.call(this, elem, types, handler, data, selector);
- };
-
- var _oldReady = $.fn.ready;
- $.fn.ready = function traceKitjQueryReadyWrapper(fn) {
- var _fn = function () {
- try {
- return fn.apply(this, arguments);
- } catch (e) {
- TraceKit.report(e);
- throw e;
- }
- };
-
- return _oldReady.call(this, _fn);
- };
-
- var _oldAjax = $.ajax;
- $.ajax = function traceKitAjaxWrapper(s) {
- if ($.isFunction(s.complete)) {
- var _oldComplete = s.complete;
- s.complete = function traceKitjQueryComplete() {
- try {
- return _oldComplete.apply(this, arguments);
- } catch (e) {
- TraceKit.report(e);
- throw e;
- }
- };
- }
-
- if ($.isFunction(s.error)) {
- var _oldError = s.error;
- s.error = function traceKitjQueryError() {
- try {
- return _oldError.apply(this, arguments);
- } catch (e) {
- TraceKit.report(e);
- throw e;
- }
- };
- }
-
- if ($.isFunction(s.success)) {
- var _oldSuccess = s.success;
- s.success = function traceKitjQuerySuccess() {
- try {
- return _oldSuccess.apply(this, arguments);
- } catch (e) {
- TraceKit.report(e);
- throw e;
- }
- };
- }
-
- try {
- return _oldAjax.call(this, s);
- } catch (e) {
- TraceKit.report(e);
- throw e;
- }
- };
-
-}(window.jQuery));
//Default options:
if (!TraceKit.remoteFetching) {
Something went wrong with that request. Please try again.