本文整理匯總了TypeScript中@core/feature/merge.mask_merge函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript mask_merge函數的具體用法?TypeScript mask_merge怎麽用?TypeScript mask_merge使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了mask_merge函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
render: function (node, model, ctx, container, ctr, els) {
var name = attr_first(node.attr);
var Compo = customTag_get(name, ctr);
var template;
if (Compo != null) {
template = Compo.prototype.template || Compo.prototype.nodes;
if (template != null) {
template = mask_merge(template, node.nodes);
}
}
else {
template = Templates.get(name);
}
if (template != null) {
builder_build(template, model, ctx, container, ctr, els);
}
}
示例2: compo_ensureTemplate
export function compo_ensureTemplate(compo) {
if (compo.nodes == null) {
compo.nodes = getTemplateProp_(compo);
return;
}
var behaviour = compo.meta.template;
if (behaviour == null || behaviour === 'replace') {
return;
}
var template = getTemplateProp_(compo);
if (template == null) {
return;
}
if (behaviour === 'merge') {
compo.nodes = mask_merge(template, compo.nodes, compo);
return;
}
if (behaviour === 'join') {
compo.nodes = [template, compo.nodes];
return;
}
log_error('Invalid meta.nodes behaviour', behaviour);
}
示例3: UTest
import { mask_merge } from '@core/feature/merge';
import { mask_stringify } from '@core/parser/exports';
UTest({
'placeholders' () {
var a = `
div > @foo;
`;
var b = `
@foo > span;
`;
var nodes = mask_merge(a, b);
var str = mask_stringify(nodes);
eq_(str, 'div>span;');
},
'join nodes outside any placeholders' () {
var a = `
div > @foo;
`;
var b = `
span;
`;
var nodes = mask_merge(a, b);
var str = mask_stringify(nodes);
eq_(str, 'div;span;');
},
'insert nodes into the root placeholder' () {
var a = `
div > @placeholder;
示例4: inherit_
function inherit_(target, source, name){
if (target == null || source == null)
return;
if ('node' === name) {
var targetNodes = target.template || target.nodes,
sourceNodes = source.template || source.nodes;
target.template = targetNodes == null || sourceNodes == null
? (targetNodes || sourceNodes)
: (mask_merge(sourceNodes, targetNodes, target, {extending: true }));
if (target.nodes != null) {
target.nodes = target.template;
}
}
var hasFnOverrides = false;
outer: for(var key in source){
if (key === 'constructor' || ('node' === name && (key === 'template' || key === 'nodes'))) {
continue;
}
var mix = source[key];
if (target[key] == null) {
target[key] = mix;
continue;
}
if ('node' === name) {
switch (key) {
case 'renderStart':
case 'renderEnd':
case 'emitIn':
case 'emitOut':
case 'components':
case 'nodes':
case 'template':
case 'find':
case 'closest':
case 'on':
case 'remove':
case 'slotState':
case 'signalState':
case 'append':
case 'appendTo':
// is sealed
continue outer;
case 'serializeState':
case 'deserializeState':
if (source[key] !== CompoProto[key]) {
target[key] = source[key];
}
continue outer;
}
}
if ('pipes' === name) {
inherit_(target[key], mix, 'pipe');
continue;
}
var type = typeof mix;
if (type === 'function') {
var fnAutoCall = false;
if ('slots' === name || 'events' === name || 'pipe' === name)
fnAutoCall = true;
else if ('node' === name && ('onRenderStart' === key || 'onRenderEnd' === key))
fnAutoCall = true;
target[key] = createWrapper_(target[key], mix, fnAutoCall);
hasFnOverrides = true;
continue;
}
if (type !== 'object') {
continue;
}
switch(key){
case 'slots':
case 'pipes':
case 'events':
case 'attr':
inherit_(target[key], mix, key);
continue;
}
defaults_(target[key], mix);
}
if (hasFnOverrides === true) {
if (target.super != null) {
log_error('`super` property is reserved. Dismissed. Current prototype', target);
}
target.super = null;
}
}