本文整理匯總了TypeScript中angular2/test_lib.stringifyElement函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript stringifyElement函數的具體用法?TypeScript stringifyElement怎麽用?TypeScript stringifyElement使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了stringifyElement函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should replace the element with an empty <template> element', () => {
var rootElement = el('<div><span template=""></span></div>');
var originalChild = rootElement.childNodes[0];
var results = createPipeline().process(rootElement);
expect(results[0].element).toBe(rootElement);
expect(stringifyElement(results[0].element))
.toEqual('<div><template class="ng-binding"></template></div>');
expect(stringifyElement(results[2].element)).toEqual('<span template=""></span>');
expect(results[2].element).toBe(originalChild);
});
示例2: it
it('should replace the element with an empty <template> element', () => {
var rootElement = DOM.createTemplate('<span template=""></span>');
var originalChild = DOM.firstChild(DOM.content(rootElement));
var results = proceess(rootElement);
expect(results[0].element).toBe(rootElement);
expect(stringifyElement(results[0].element))
.toEqual('<template><template class="ng-binding"></template></template>');
expect(stringifyElement(results[2].element))
.toEqual('<template><span template=""></span></template>');
expect(DOM.firstChild(DOM.content(results[2].element))).toBe(originalChild);
});
示例3: it
it('should clone correctly', () => {
var el1 = el('<div x="y">a<span>b</span></div>');
var clone = DOM.clone(el1);
expect(clone).not.toBe(el1);
DOM.setAttribute(clone, 'test', '1');
expect(stringifyElement(clone)).toEqual('<div test="1" x="y">a<span>b</span></div>');
expect(DOM.getAttribute(el1, 'test')).toBeFalsy();
var cNodes = DOM.childNodes(clone);
var firstChild = cNodes[0];
var secondChild = cNodes[1];
expect(DOM.parentElement(firstChild)).toBe(clone);
expect(DOM.nextSibling(firstChild)).toBe(secondChild);
expect(DOM.isTextNode(firstChild)).toBe(true);
expect(DOM.parentElement(secondChild)).toBe(clone);
expect(DOM.nextSibling(secondChild)).toBeFalsy();
expect(DOM.isElementNode(secondChild)).toBe(true);
});