How to use the ember-metal/assign 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-htmlbars / lib / hooks / component.js View on Github external
if (isComponentCell(componentCell)) {
      tagName = componentCell[COMPONENT_PATH];

      /*
       * Processing positional params before merging into a hash must be done
       * here to avoid problems with rest positional parameters rendered using
       * the dot notation.
       *
       * Closure components (for the contextual component feature) do not
       * actually keep the positional params, but process them at each level.
       * Therefore, when rendering a closure component with the component
       * helper we process the parameters and attributes and then merge those
       * on top of the closure component attributes.
       *
       */
      let newAttrs = assign(new EmptyObject(), attrs);
      processPositionalParamsFromCell(componentCell, params, newAttrs);
      attrs = mergeInNewHash(componentCell[COMPONENT_HASH],
                             newAttrs,
                             componentCell[COMPONENT_POSITIONAL_PARAMS],
                             params);
      params = [];
    }
  }

  // Determine if this is an initial render or a re-render.
  if (state.manager) {
    let sm = state.manager;
    let templateMeta = null;
    if (sm.block) {
      templateMeta = sm.block.template.meta;
    } else if (sm.scope && sm.scope._view && sm.scope._view.template) {
github emberjs / ember.js / packages / ember-htmlbars / lib / keywords / element-component.js View on Github external
setupState(lastState, env, scope, params, hash) {
    let componentPath = getComponentPath(params[0], env);
    return assign({}, lastState, {
      componentPath,
      isComponentHelper: true
    });
  },
github emberjs / ember.js / packages / ember-htmlbars-template-compiler / lib / system / compile-options.js View on Github external
function mergePlugins(options = {}) {
  options = assign({}, options);
  if (!options.plugins) {
    options.plugins = { ast: [...USER_PLUGINS, ...PLUGINS] };
  } else {
    let potententialPugins = [...USER_PLUGINS, ...PLUGINS];
    let pluginsToAdd = potententialPugins.filter((plugin) => {
      return options.plugins.ast.indexOf(plugin) === -1;
    });

    options.plugins.ast = options.plugins.ast.slice().concat(pluginsToAdd);
  }

  return options;
}
github emberjs / ember.js / packages / ember-htmlbars / lib / env.js View on Github external
import classify from './hooks/classify';
import component from './hooks/component';
import lookupHelper from './hooks/lookup-helper';
import hasHelper from './hooks/has-helper';
import invokeHelper from './hooks/invoke-helper';
import element from './hooks/element';

import helpers from './helpers';
import keywords, { registerKeyword } from './keywords';

import DOMHelper from './system/dom-helper';

const emberHooks = assign({}, hooks);
emberHooks.keywords = keywords;

assign(emberHooks, {
  linkRenderNode,
  createFreshScope,
  createChildScope,
  bindShadowScope,
  bindSelf,
  bindScope,
  bindLocal,
  bindBlock,
  updateSelf,
  getBlock,
  getRoot,
  getChild,
  getValue,
  getCellOrValue,
  subexpr,
  concat,
github emberjs / ember.js / packages / ember-htmlbars / lib / keywords / closure-component.js View on Github external
export function mergeInNewHash(original, updates, positionalParams=[], params=[]) {
  let newHash = assign({}, original, updates);

  if (isRestPositionalParams(positionalParams) && isEmpty(params)) {
    let propName = positionalParams;
    newHash[propName] = original[propName];
  }

  return newHash;
}
github emberjs / ember.js / packages / ember-htmlbars / lib / streams / dependency.js View on Github external
@private
  @class Dependency
  @namespace Ember.streams
  @constructor
*/
export default function Dependency(depender, dependee) {
  assert('Dependency error: Depender must be a stream', isStream(depender));

  this.next = null;
  this.prev = null;
  this.depender = depender;
  this.dependee = dependee;
  this.unsubscription = null;
}

assign(Dependency.prototype, {
  subscribe() {
    assert('Dependency error: Dependency tried to subscribe while already subscribed', !this.unsubscription);

    this.unsubscription = subscribe(this.dependee, this.depender.notify, this.depender);
  },

  unsubscribe() {
    if (this.unsubscription) {
      this.unsubscription();
      this.unsubscription = null;
    }
  },

  replace(dependee) {
    if (this.dependee !== dependee) {
      this.dependee = dependee;
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 / component.js View on Github external
export default function(morph, env, scope, params, hash, template, inverse, visitor) {
  if (!morph) {
    return closureComponent(env, params, hash);
  }

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

  keyword('@element_component', morph, env, scope, params, newHash, template, inverse, visitor);
  return true;
}
github emberjs / ember.js / packages / ember-htmlbars / lib / streams / subscriber.js View on Github external
*/

/**
  @private
  @class Subscriber
  @namespace Ember.streams
  @constructor
*/
export default function Subscriber(callback, context) {
  this.next = null;
  this.prev = null;
  this.callback = callback;
  this.context = context;
}

assign(Subscriber.prototype, {
  removeFrom(stream) {
    let next = this.next;
    let prev = this.prev;

    if (prev) {
      prev.next = next;
    } else {
      stream.subscriberHead = next;
    }

    if (next) {
      next.prev = prev;
    } else {
      stream.subscriberTail = prev;
    }