Skip to content
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

Uncaught TypeError: Cannot read property 'render' of undefined #259

Closed
miguelmota opened this issue Apr 15, 2015 · 3 comments
Closed

Uncaught TypeError: Cannot read property 'render' of undefined #259

miguelmota opened this issue Apr 15, 2015 · 3 comments

Comments

@miguelmota
Copy link

screen shot 2015-04-15 at 1 33 46 pm

ember-internals.js

define('liquid-fire/ember-internals', ['exports', 'ember'], function (exports, Ember) {

  'use strict';

  exports.containingElement = containingElement;
  exports.makeHelperShim = makeHelperShim;
  exports.inverseYieldHelper = inverseYieldHelper;
  exports.inverseYieldMethod = inverseYieldMethod;
  exports.routeName = routeName;
  exports.routeModel = routeModel;

  // Given an Ember.View, return the containing element
  var get = Ember['default'].get;
  var set = Ember['default'].set;
  function containingElement(view) {
    return view._morph.contextualElement;
  }

  function makeHelperShim(componentName, tweak) {
    return {
      isHTMLBars: true,
      helperFunction: function liquidFireHelper(params, hash, options, env) {
        var view = env.data.view;
        var componentLookup = view.container.lookup("component-lookup:main");
        var cls = componentLookup.lookupFactory(componentName);
        hash.value = params[0];
        if (hash["class"]) {
          hash.innerClass = hash["class"];
          delete hash["class"];
        }
        if (hash.id) {
          hash.innerId = hash.id;
          delete hash.id;
        }
        hash.tagName = "";
        if (tweak) {
          tweak(params, hash, options, env);
        }
        env.helpers.view.helperFunction.call(view, [cls], hash, options, env);
      }
    };
  }

  function inverseYieldHelper(params, hash, options, env) {
    var view = env.data.view;

    while (view && !get(view, "layout")) {
      if (view._contextView) {
        view = view._contextView;
      } else {
        view = view._parentView;
      }
    }

    return view._yieldInverse(env.data.view, env, options.morph, params);
  }

  function inverseYieldMethod(context, options, morph, blockArguments) {
    var view = options.data.view;
    var parentView = this._parentView;
    var template = get(this, "inverseTemplate");

    if (template) {
      view.appendChild(Ember['default'].View, {
        isVirtual: true,
        tagName: "",
        template: template,
        _blockArguments: blockArguments,
        _contextView: parentView,
        _morph: morph,
        context: get(parentView, "context"),
        controller: get(parentView, "controller")
      });
    }
  }

  // This lets us hook into the outlet state.
  var OutletBehavior = {
    _isOutlet: true,

    init: function init() {
      this._super();
      this._childOutlets = [];

      // Our outlet state is named differently than a normal ember
      // outlet ("_outletState"), so that our child outlets don't
      // automatically discover it. Instead we will always push state
      // down to them, so we can version it as we wish.
      this.outletState = null;
    },

    setOutletState: function setOutletState(state) {
      if (state.render && state.render.controller && !state._lf_model) {
        // This is a hack to compensate for Ember 1.0's remaining use of
        // mutability within the route state -- the controller is a
        // singleton whose model will keep changing on us. By locking it
        // down the first time we see the state, we can more closely
        // emulate ember 2.0 semantics.
        //
        // The Ember 2.0 component attributes shouldn't suffer this
        // problem and we can eventually drop the hack.
        state = Ember['default'].copy(state);
        state._lf_model = get(state.render.controller, "model");
      }

      if (!this._diffState(state)) {
        var children = this._childOutlets;
        for (var i = 0; i < children.length; i++) {
          var child = children[i];
          child.setOutletState(state);
        }
      }
    },

    _diffState: function _diffState(state) {
      while (state && emptyRouteState(state)) {
        state = state.outlets.main;
      }
      var different = !sameRouteState(this.outletState, state);

      if (different) {
        set(this, "outletState", state);
      }

      return different;
    },

    _parentOutlet: function _parentOutlet() {
      var parent = this._parentView;
      while (parent && !parent._isOutlet) {
        parent = parent._parentView;
      }
      return parent;
    },

    _linkParent: Ember['default'].on("init", "parentViewDidChange", function () {
      var parent = this._parentOutlet();
      if (parent) {
        this._parentOutletLink = parent;
        parent._childOutlets.push(this);
        if (parent._outletState && parent._outletState.outlets[this._outletName]) {
          this.setOutletState(parent._outletState.outlets[this._outletName]);
        }
      }
    }),

    willDestroy: function willDestroy() {
      if (this._parentOutletLink) {
        this._parentOutletLink._childOutlets.removeObject(this);
      }
      this._super();
    }
  };

  function emptyRouteState(state) {
    return !state.render.ViewClass && !state.render.template;
  }

  function sameRouteState(a, b) {
    if (!a && !b) {
      return true;
    }
    if (!a || !b) {
      return false;
    }
    a = a.render;
    b = b.render;
    for (var key in a) {
      if (a.hasOwnProperty(key)) {
        // name is only here for logging & debugging. If two different
        // names result in otherwise identical states, they're still
        // identical.
        if (a[key] !== b[key] && key !== "name") {
          return false;
        }
      }
    }
    return true;
  }

  // This lets us invoke an outlet with an explicitly passed outlet
  // state, rather than inheriting it implicitly from its context.
  var StaticOutlet = Ember['default'].OutletView.superclass.extend({
    tagName: "",

    setStaticState: Ember['default'].on("init", Ember['default'].observer("staticState", function () {
      this.setOutletState(this.get("staticState"));
    }))
  });function routeName(routeState) {
    if (routeState && routeState.render) {
      return [routeState.render.name];
    }
  }

  function routeModel(routeState) {
    if (routeState) {
      return [routeState._lf_model];
    }
  }

  exports.OutletBehavior = OutletBehavior;
  exports.StaticOutlet = StaticOutlet;

});

Versions

EBUG: -------------------------------
ember.debug.js:4930DEBUG: Ember      : 1.13.0-beta.1+canary.ffedc10e
ember.debug.js:4930DEBUG: Ember Data : 1.0.0-beta.17+canary.5887afe8a1
ember.debug.js:4930DEBUG: jQuery     : 2.1.3
ember.debug.js:4930DEBUG: -------------------------------

package.json

  "devDependencies": {
    "body-parser": "^1.2.0",
    "bourbon-libsass": "^1.0.0",
    "broccoli-asset-rev": "^2.0.2",
    "broccoli-sass-source-maps": "^0.7.0",
    "chalk": "^0.5.1",
    "ember-cli": "0.2.3",
    "ember-cli-app-version": "0.3.3",
    "ember-cli-babel": "^5.0.0",
    "ember-cli-content-security-policy": "^0.4.0",
    "ember-cli-dependency-checker": "0.0.8",
    "ember-cli-htmlbars": "0.7.4",
    "ember-cli-ic-ajax": "0.1.1",
    "ember-cli-inject-live-reload": "^1.3.0",
    "ember-cli-pretender": "^0.3.1",
    "ember-cli-qunit": "0.3.10",
    "ember-cli-sass": "^4.0.0-beta.5",
    "ember-cli-uglify": "1.0.1",
    "ember-data": "1.0.0-beta.16.1",
    "ember-export-application-global": "^1.0.2",
    "ember-template-compiler": "^1.9.0-alpha",
    "express": "^4.8.5",
    "fs-extra": "^0.12.0",
    "glob": "^4.0.5",
    "grunt": "^0.4.5",
    "grunt-contrib-yuidoc": "^0.5.2",
    "grunt-jsdoc": "^0.5.7",
    "grunt-remove-logging": "^0.2.0",
    "grunt-shell": "^1.1.1",
    "grunt-strip": "^0.2.1",
    "handlebars": "^2.0.0",
    "inflection": "^1.4.1",
    "liquid-fire": "^0.19.2",
    "lodash": "^2.4.1",
    "path": "^0.4.9"
  }

My code

routes/application.js

  openModal: function() {
      return this.render('my-modal', {
        into: 'application',
        outlet: 'modal'
      });
  }

application.hbs

{{ outlet "modal" }}

my-modal.hbs

Hope that helps.

@ef4
Copy link
Collaborator

ef4 commented Apr 15, 2015

This is a duplicate of #239 which is fixed and released in 0.19.3.

@ef4 ef4 closed this as completed Apr 15, 2015
@jamesmenera
Copy link

@ef4 Awesome that fixed it. Thanks!

@miguelmota
Copy link
Author

Cool thanks, upgrading did the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants