How to use the ember-metal/core.assert function in ember-metal

To help you get started, we’ve selected a few ember-metal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github emberjs / ember.js / packages / ember-handlebars / lib / helpers / view.js View on Github external
extensions.classNames = classes;
    }

    if (hash.classBinding) {
      extensions.classNameBindings = hash.classBinding.split(' ');
    }

    if (hash.classNameBindings) {
      if (extensions.classNameBindings === undefined) {
        extensions.classNameBindings = [];
      }
      extensions.classNameBindings = extensions.classNameBindings.concat(hash.classNameBindings.split(' '));
    }

    if (hash.attributeBindings) {
      Ember.assert("Setting 'attributeBindings' via template helpers is not allowed." +
                   " Please subclass Ember.View and set it there instead.");
      extensions.attributeBindings = null;
    }

    // Set the proper context for all bindings passed to the helper. This applies to regular attribute bindings
    // as well as class name bindings. If the bindings are local, make them relative to the current context
    // instead of the view.

    var hashKeys = keys(hash);

    for (var i = 0, l = hashKeys.length; i < l; i++) {
      var prop = hashKeys[i];

      if (prop !== 'classNameBindings') {
        extensions[prop] = hash[prop];
      }
github emberjs / ember.js / packages / ember-routing-htmlbars / lib / helpers / render.js View on Github external
export function renderHelper(params, hash, options, env) {
  var currentView = env.data.view;
  var container, router, controller, view, initialContext;

  var name = params[0];
  var context = params[1];

  container = currentView._keywords.controller.value().container;
  router = container.lookup('router:main');

  Ember.assert(
    "The first argument of {{render}} must be quoted, e.g. {{render \"sidebar\"}}.",
    typeof name === 'string'
  );

  Ember.assert(
    "The second argument of {{render}} must be a path, e.g. {{render \"post\" post}}.",
    params.length < 2 || isStream(params[1])
  );


  if (params.length === 1) {
    // use the singleton controller
    Ember.assert(
      "You can only use the {{render}} helper once without a model object as " +
      "its second argument, as in {{render \"post\" post}}.",
      !router || !router._lookupActiveView(name)
github emberjs / ember.js / packages / ember-handlebars / lib / helpers / view.js View on Github external
instanceHelper: function(thisContext, newView, options) {
    var data = options.data;
    var fn   = options.fn;

    makeBindings(options);

    Ember.assert(
      'Only a instance of a view may be passed to the ViewHelper.instanceHelper',
      View.detectInstance(newView)
    );

    var viewOptions = this.propertiesFromHTMLOptions(options, thisContext);
    var currentView = data.view;
    viewOptions.templateData = data;

    if (fn) {
      Ember.assert("You cannot provide a template block if you also specified a templateName",
                   !get(viewOptions, 'templateName') && !get(newView, 'templateName'));
      viewOptions.template = fn;
    }

    // We only want to override the `_context` computed property if there is
    // no specified controller. See View#_context for more information.
github emberjs / ember.js / packages / ember-runtime / lib / system / object.js View on Github external
function injectedPropertyAssertion(props) {
  // Injection validations are a debugging aid only, so ensure that they are
  // not performed in production builds by invoking from an assertion
  Ember.assert("Injected properties are invalid", validatePropertyInjections(this.constructor, props));
}
github emberjs / ember.js / packages / ember-runtime / lib / system / each_proxy.js View on Github external
function addObserverForContentKey(content, keyName, proxy, idx, loc) {
  var objects = proxy._objects;
  var guid;
  if (!objects) objects = proxy._objects = {};

  while(--loc>=idx) {
    var item = content.objectAt(loc);
    if (item) {
      Ember.assert('When using @each to observe the array ' + content + ', the array must return an object', typeOf(item) === 'instance' || typeOf(item) === 'object');
      addBeforeObserver(item, keyName, proxy, 'contentKeyWillChange');
      addObserver(item, keyName, proxy, 'contentKeyDidChange');

      // keep track of the index each item was found at so we can map
      // it back when the obj changes.
      guid = guidFor(item);
      if (!objects[guid]) objects[guid] = [];
      objects[guid].push(loc);
    }
  }
}
github emberjs / ember.js / packages_es6 / ember-views / lib / system / jquery.js View on Github external
/**
Ember Views

@module ember
@submodule ember-views
@requires ember-runtime
@main ember-views
*/

var jQuery = (Ember.imports && Ember.imports.jQuery) || (this && this.jQuery);
if (!jQuery && typeof require === 'function') {
  jQuery = require('jquery');
}

Ember.assert("Ember Views require jQuery between 1.7 and 2.1", jQuery && (jQuery().jquery.match(/^((1\.(7|8|9|10|11))|(2\.(0|1)))(\.\d+)?(pre|rc\d?)?/) || Ember.ENV.FORCE_JQUERY));

/**
@module ember
@submodule ember-views
*/
if (jQuery) {
  // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dndevents
  var dragEvents = w('dragstart drag dragenter dragleave dragover drop dragend');

  // Copies the `dataTransfer` property from a browser event object onto the
  // jQuery event object for the specified events
  forEach(dragEvents, function(eventName) {
    jQuery.event.fixHooks[eventName] = { props: ['dataTransfer'] };
  });
}
github emberjs / ember.js / packages / ember-application / lib / ext / controller.js View on Github external
function verifyNeedsDependencies(controller, container, needs) {
  var dependency, i, l;
  var missing = [];

  for (i=0, l=needs.length; i 1 ? 'they' : 'it') + " could not be found");
  }
}
github emberjs / ember.js / packages / ember-views / lib / compat / render_buffer.js View on Github external
hydrateMorphs(contextualElement) {
    var childViews = this.childViews;
    var el = this._element;
    for (var i = 0, l = childViews.length; i < l; i++) {
      var childView = childViews[i];
      var ref = el.querySelector('#morph-' + i);

      Ember.assert('An error occurred while setting up template bindings. Please check ' +
                   (((childView && childView.parentView && childView._parentView._debugTemplateName ? '"' + childView._parentView._debugTemplateName + '" template ' : ''))
                   )  + 'for invalid markup or bindings within HTML comments.',
                   ref);

      var parent = ref.parentNode;

      childView._morph = this.dom.insertMorphBefore(
        parent,
        ref,
        parent.nodeType === 1 ? parent : contextualElement
      );
      parent.removeChild(ref);
    }
  },
github emberjs / ember.js / packages / ember-htmlbars / lib / helpers / bind-attr.js View on Github external
path = hash[attr];
    if (isStream(path)) {
      lazyValue = path;
    } else {
      Ember.assert(
        fmt("You must provide an expression as the value of bound attribute." +
            " You specified: %@=%@", [attr, path]),
        typeof path === 'string'
      );
      lazyValue = view.getStream(path);
    }

    attrView = new LegacyBindAttrNode(attr, lazyValue);
    attrView._morph = env.dom.createAttrMorph(element, attr);

    Ember.assert(
      'You cannot set `' + attr + '` manually and via `{{bind-attr}}` helper on the same element.',
      !element.getAttribute(attr)
    );

    view.appendChild(attrView);
  }
}
github emberjs / ember.js / packages / ember-routing-handlebars / lib / helpers / query_params.js View on Github external
export function queryParamsHelper(options) {
  Ember.assert(fmt("The `query-params` helper only accepts hash parameters, e.g. (query-params queryParamPropertyName='%@') as opposed to just (query-params '%@')", [options, options]), arguments.length === 1);

  var view = options.data.view;
  var hash = options.hash;
  var hashTypes = options.hashTypes;

  for (var k in hash) {
    if (hashTypes[k] === 'ID') {
      hash[k] = view.getStream(hash[k]);
    }
  }

  return QueryParams.create({
    values: options.hash
  });
}