Sha256: 1ebfeb0851649525cfee1d3cede1b2a52b0e72815895680448c4f153603b1088
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
import { symbol } from 'ember-utils'; import { MUTABLE_CELL } from 'ember-views'; import { ARGS } from '../component'; import { ACTION, UPDATE } from './references'; // ComponentArgs takes EvaluatedNamedArgs and converts them into the // inputs needed by CurlyComponents (attrs and props, with mutable // cells, etc). export function processComponentArgs(namedArgs) { let keys = namedArgs.names; let attrs = namedArgs.value(); let props = Object.create(null); let args = Object.create(null); props[ARGS] = args; for (let i = 0; i < keys.length; i++) { let name = keys[i]; let ref = namedArgs.get(name); let value = attrs[name]; if (typeof value === 'function' && value[ACTION]) { attrs[name] = value; } else if (ref[UPDATE]) { attrs[name] = new MutableCell(ref, value); } args[name] = ref; props[name] = value; } props.attrs = attrs; return props; } const REF = symbol('REF'); class MutableCell { constructor(ref, value) { this[MUTABLE_CELL] = true; this[REF] = ref; this.value = value; } update(val) { this[REF][UPDATE](val); } }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
discourse-ember-source-3.5.1.1 | dist/es/ember-glimmer/lib/utils/process-args.js |
discourse-ember-source-3.5.1.0 | dist/dist/es/ember-glimmer/lib/utils/process-args.js |