query-engine icon indicating copy to clipboard operation
query-engine copied to clipboard

reading property of undefined

Open Thomas-P opened this issue 10 years ago • 0 comments

If i use query-engine as a common module and convert them with browserify, then i got an error in line 5 of query-engine.js. This is the extend function of coffeescript, but it themes that the Backbone variable is the problem.

If i change

(function() {
  var Backbone, Criteria, Hash, Pill, Query, QueryCollection, queryEngine, util, _ref,
    __hasProp = {}.hasOwnProperty,
    __slice = [].slice,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
    __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

  Backbone = this.Backbone || (typeof window !== "undefined" && window !== null ? window.Backbone : void 0) || ((function() {
    try {
      return typeof require === "function" ? require('backbone') : void 0;
    } catch (_error) {}
  })()) || ((function() {
    try {
      return typeof require === "function" ? require('exoskeleton') : void 0;
    } catch (_error) {}
  })()) || null;

  util = { [...]

to


(function() {
  var Backbone, Criteria, Hash, Pill, Query, QueryCollection, queryEngine, util, _ref,
    __hasProp = {}.hasOwnProperty,
    __slice = [].slice,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
    __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

  Backbone = null;

  util = { [...]

it works fine. So i tested what i got back at the Backbone declaration. It themes that i will got an object instead of null. So the following parts act as i loaded Backbone an will extend functionallity from an undefined object. I hope it is not so confusing.

Thomas

Thomas-P avatar May 12 '15 09:05 Thomas-P