How to use the ember-metal/debug.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-views / lib / components / component.js View on Github external
if (this.defaultLayout && !this.layout) {
      deprecate(
        `Specifying \`defaultLayout\` to ${this} is deprecated. Please use \`layout\` instead.`,
        false,
        {
          id: 'ember-views.component.defaultLayout',
          until: '3.0.0',
          url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-component-defaultlayout'
        }
      );

      this.layout = this.defaultLayout;
    }

    // If in a tagless component, assert that no event handlers are defined
    assert(
      `You can not define a function that handles DOM events in the \`${this}\` tagless component since it doesn't have any DOM element.`,
      this.tagName !== '' || !environment.hasDOM || !(() => {
        let eventDispatcher = getOwner(this).lookup('event_dispatcher:main');
        let events = (eventDispatcher && eventDispatcher._finalEvents) || {};

        for (let key in events) {
          let methodName = events[key];

          if (typeof this[methodName]  === 'function') {
            return true; // indicate that the assertion should be triggered
          }
        }
      }
    )());
  },
github emberjs / ember.js / packages / ember-application / lib / system / application.js View on Github external
reset() {
    assert(`Calling reset() on instances of \`Ember.Application\` is not
            supported when globals mode is disabled; call \`visit()\` to
            create new \`Ember.ApplicationInstance\`s and dispose them
            via their \`destroy()\` method instead.`, this._globalsMode && this.autoboot);

    var instance = this.__deprecatedInstance__;

    this._readinessDeferrals = 1;
    this._bootPromise = null;
    this._bootResolver = null;
    this._booted = false;

    function handleReset() {
      run(instance, 'destroy');
      this._buildDeprecatedInstance();
      run.schedule('actions', this, '_bootSync');
    }
github emberjs / ember.js / packages / ember-htmlbars / lib / keywords / closure-component.js View on Github external
function createClosureComponentCell(env, originalComponentPath, params, hash, label) {
  let componentPath = read(originalComponentPath);

  assert(`Component path cannot be null in ${label}`,
         !isNone(componentPath));

  let newHash = assign(new EmptyObject(), hash);

  if (isComponentCell(componentPath)) {
    return createNestedClosureComponentCell(componentPath, params, newHash);
  } else {
    assert(`The component helper cannot be used without a valid component name. You used "${componentPath}" via ${label}`,
          isValidComponentPath(env, componentPath));
    return createNewClosureComponentCell(env, componentPath, params, newHash);
  }
}
github emberjs / ember.js / packages / ember-htmlbars / lib / keywords / mount.js View on Github external
setupState(prevState, env, scope, params /*, hash */) {
    let name = params[0];

    assert(
      'The first argument of {{mount}} must be an engine name, e.g. {{mount "chat-engine"}}.',
      params.length === 1
    );

    assert(
      'The first argument of {{mount}} must be quoted, e.g. {{mount "chat-engine"}}.',
      typeof name === 'string'
    );

    assert(
      'You used `{{mount \'' + name + '\'}}`, but the engine \'' + name + '\' can not be found.',
      env.owner.hasRegistration(`engine:${name}`)
    );

    let engineInstance = env.owner.buildChildEngineInstance(name);

    engineInstance.boot();

    let state = {
      parentView: env.view,
      manager: prevState.manager,
      controller: lookupEngineController(engineInstance),
      childOutletState: childOutletState(name, env)
    };

    setOwner(state, engineInstance);
github emberjs / ember.js / packages / ember-application / lib / system / application.js View on Github external
advanceReadiness() {
    assert('You must call advanceReadiness on an instance of Ember.Application', this instanceof Application);
    this._readinessDeferrals--;

    if (this._readinessDeferrals === 0) {
      run.once(this, this.didBecomeReady);
    }
  },
github emberjs / ember.js / packages / ember-htmlbars / lib / streams / class_name_binding.js View on Github external
export function streamifyClassNameBinding(view, classNameBinding, prefix) {
  prefix = prefix || '';
  assert('classNameBindings must not have spaces in them. Multiple class name bindings can be provided as elements of an array, e.g. [\'foo\', \':bar\']', classNameBinding.indexOf(' ') === -1);
  let parsedPath = parsePropertyPath(classNameBinding);
  if (parsedPath.path === '') {
    return classStringForValue(
      parsedPath.path,
      true,
      parsedPath.className,
      parsedPath.falsyClassName
    );
  } else {
    let pathValue = view.getStream(prefix + parsedPath.path);
    return chain(pathValue, () => {
      return classStringForValue(
        parsedPath.path,
        read(pathValue),
        parsedPath.className,
        parsedPath.falsyClassName
github emberjs / ember.js / packages / ember-template-compiler / lib / plugins / assert-no-view-helper.js View on Github external
function assertHelper(moduleName, node) {
  let paramValue = node.params.length && node.params[0].value;

  if (!paramValue) {
    return;
  } else {
    assert(
      `Using the \`{{view "string"}}\` helper is removed in 2.0. ${calculateLocationDisplay(moduleName, node.loc)}`,
      ENV._ENABLE_LEGACY_VIEW_SUPPORT,
      { id: 'view.helper', until: '2.0.0' }
    );
  }
}
github emberjs / ember.js / packages / ember-views / lib / views / collection_view.js View on Github external
_assertArrayLike(content) {
    assert(`an Ember.CollectionView's content must implement Ember.Array. You passed ${content}`, EmberArray.detect(content));
  },
github emberjs / ember.js / packages / ember-htmlbars / lib / keywords / mut.js View on Github external
function mutParam(read, stream, internal) {
  if (internal) {
    if (!isStream(stream)) {
      let literal = stream;
      stream = new LiteralStream(literal);
    }
  } else {
    assert('You can only pass a path to mut', isStream(stream));
  }

  if (stream[MUTABLE_REFERENCE]) {
    return stream;
  }

  return new MutStream(stream);
}
github emberjs / ember.js / packages / ember-htmlbars / lib / keywords / mount.js View on Github external
setupState(prevState, env, scope, params /*, hash */) {
    let name = params[0];

    assert(
      'The first argument of {{mount}} must be an engine name, e.g. {{mount "chat-engine"}}.',
      params.length === 1
    );

    assert(
      'The first argument of {{mount}} must be quoted, e.g. {{mount "chat-engine"}}.',
      typeof name === 'string'
    );

    assert(
      'You used `{{mount \'' + name + '\'}}`, but the engine \'' + name + '\' can not be found.',
      env.owner.hasRegistration(`engine:${name}`)
    );

    let engineInstance = env.owner.buildChildEngineInstance(name);

    engineInstance.boot();

    let state = {
      parentView: env.view,
      manager: prevState.manager,