当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript merge.mask_merge函数代码示例

本文整理汇总了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);
        }
    }
开发者ID:atmajs,项目名称:MaskJS,代码行数:18,代码来源:template.ts

示例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);
}
开发者ID:atmajs,项目名称:MaskJS,代码行数:23,代码来源:compo.ts

示例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;
开发者ID:atmajs,项目名称:MaskJS,代码行数:30,代码来源:merge.spec.ts

示例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;
    }
}
开发者ID:atmajs,项目名称:MaskJS,代码行数:91,代码来源:compo_inherit.ts


注:本文中的@core/feature/merge.mask_merge函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。