本文整理匯總了TypeScript中@mask-j/jMask.jMask函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript jMask函數的具體用法?TypeScript jMask怎麽用?TypeScript jMask使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了jMask函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: mask_optimize
mask_optimize(frag, assert.await(function(frag){
var baz = jMask(frag).filter('baz');
eq_(baz.length, 0);
txt = jMask(frag).filter('span').text();
eq_(txt, 'Baz');
done();
}));
示例2: parser_parse
.forEach(data => {
var {template, expect} = data;
var nodes = parser_parse(template);
var node = jMask(nodes).find('import').get(0);
is_(node, 'Object');
expect(node);
var str = mask_stringify(node);
eq_(template, str);
})
示例3: function
$getNode: function (id, filter) {
var ctx = this, node;
while (ctx != null) {
node = ctx[id];
if (node != null)
break;
ctx = ctx.parent;
}
if (filter != null && node != null) {
node = {
nodes: jMask(node.nodes).filter(filter)
};
}
return node;
}
示例4: function
.done(function(str) {
// remove all remote styles
var ast = mask_TreeWalker.walk(str, function(node){
if (node.tagName === 'link' && node.attr.href) {
return { remove: true };
}
});
ast = jMask('module')
.attr('path', path)
.append(ast);
var str = mask_stringify(ast[0], {
indent: opts.minify ? 0 : 4
});
resolve(str);
});
示例5: function
render: function(model, ctx, container) {
this.html = jMask(this.nodes).text(model, ctx, this);
if (container.insertAdjacentHTML) {
container.insertAdjacentHTML('beforeend', this.html);
return;
}
if (container.ownerDocument) {
var div = document.createElement('div'),
child;
div.innerHTML = this.html;
child = div.firstChild;
while (child != null) {
container.appendChild(child);
child = child.nextSibling;
}
}
},
示例6: function
progress_: function(ctx, container){
var nodes = this.progressNodes;
if (nodes == null) {
return;
}
var hasLiteral = nodes.some(function(x){
return x.type === Dom.TEXTNODE;
});
if (hasLiteral) {
nodes = jMask('div').append(nodes);
}
var node = {
type: Dom.COMPONENT,
nodes: nodes,
controller: new Component,
attr: {},
};
builder_build(node, null, ctx, container, this);
},
示例7: parser_parse
].forEach(x => {
var nodes = parser_parse('div { ' + x.template + '}'),
$nodes = jMask(nodes),
$vars = $nodes.find('var');
eq_($vars.length, x.varNames.length);
$vars.each(($var, i) => {
var key = x.varNames[i];
$var = $var.attr[key];
is_($var, 'String');
deepEq_(
expression_eval($var),
x.expect[key]
);
})
});
示例8: function
constructor: function(node, model, ctx, el, ctr){
var content = node.content;
if (content == null && node.nodes) {
var x = node.nodes[0];
if (x.type === Dom.TEXTNODE) {
content = x.content;
} else {
content = jMask(x.nodes).text(model, ctr);
}
}
this.id = node.id;
this.body = is_Function(content)
? content('node', model, ctx, el, ctr)
: content
;
if (this.tagName === 'style') {
this.body = css_ensureScopedStyles(this.body, node, el);
}
}
示例9: function
resolve: function(node, id){
var nodes = cache_[id];
if (nodes != null)
return nodes;
var selector = ':template[id=' + id +']',
parent = node.parent,
tmpl = null
;
while (parent != null) {
tmpl = jMask(parent.nodes)
.filter(selector)
.get(0);
if (tmpl != null)
return tmpl.nodes;
parent = parent.parent;
}
log_warn('Template was not found', id);
return null;
},
示例10: UTest
import { parser_parse } from '@core/parser/exports';
import { jMask } from '@mask-j/jMask';
UTest({
'content':{
'block' () {
var template = `script {"A"}`;
var node = parser_parse(template);
eq_(node.content, '"A"');
},
'nodes' () {
var template = `script > :html {"A"}`;
var node = parser_parse(template);
eq_(node.nodes[0].tagName, ':html');
var txt = jMask(node).text();
eq_(txt, 'A');
},
},
'attribute' : {
'block' () {
var template = `script type='text/mask' {"A"}`;
var node = parser_parse(template);
eq_(node.content, '"A"');
eq_(node.attr.type, 'text/mask');
},
'literal' () {
var template = `script type='text/mask' > '<A>'baz`;
var nodes = parser_parse(template).nodes;
eq_(nodes[0].content, '<A>');
eq_(nodes[0].attr.type, 'text/mask');