本文整理汇总了TypeScript中angular2/src/dom/dom_adapter.DOM.hasClass方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DOM.hasClass方法的具体用法?TypeScript DOM.hasClass怎么用?TypeScript DOM.hasClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/src/dom/dom_adapter.DOM
的用法示例。
在下文中一共展示了DOM.hasClass方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should de-normalize class names', () => {
view.setElementClass(0, 'veryActive', true);
expect(DOM.hasClass(el, 'very-active')).toEqual(true);
view.setElementClass(0, 'veryActive', false);
expect(DOM.hasClass(el, 'very-active')).toEqual(false);
});
示例2: it
it('should add CSS classes if "class" specified in host element attributes', () => {
var element = el('<input class="foo baz" some-decor-with-host-attrs>');
var results = process(element);
expect(DOM.hasClass(results[0].element, 'foo')).toBeTruthy();
expect(DOM.hasClass(results[0].element, 'bar')).toBeTruthy();
expect(DOM.hasClass(results[0].element, 'baz')).toBeTruthy();
});
示例3: it
it('should return a setter for a class', () => {
var setterFn = setterFactory('class.active');
setterFn(div, true);
expect(DOM.hasClass(div, 'active')).toEqual(true);
setterFn(div, false);
expect(DOM.hasClass(div, 'active')).toEqual(false);
var otherSetterFn = setterFactory('class.active');
expect(setterFn).toBe(otherSetterFn);
});
示例4: it
it('should de-normalize class names', () => {
var setterFn = setterFactory.createSetter(div, false, 'class.veryActive');
setterFn(div, true);
expect(DOM.hasClass(div, 'very-active')).toEqual(true);
setterFn(div, false);
expect(DOM.hasClass(div, 'very-active')).toEqual(false);
var otherSetterFn = setterFactory.createSetter(div, false, 'class.veryActive');
expect(setterFn).toBe(otherSetterFn);
});
示例5: expect
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
var childTestEls = rootTestComponent.queryAll(By.directive(MessageDir), Scope.view);
expect(childTestEls.length).toBe(2);
expect(DOM.hasClass(childTestEls[0].domElement, 'parent')).toBe(true);
expect(DOM.hasClass(childTestEls[1].domElement, 'parentnested')).toBe(true);
async.done();
});
示例6: _dfsAndCreateNativeElements
_dfsAndCreateNativeElements(childrenParam, boundElements) {
var resultingNativeChildren = [];
for (var i = 0; i < childrenParam.length; i++) {
var node = childrenParam[i];
var nativeElement;
if (node.type == "tag") {
nativeElement = new ReactNativeElement(node.name, node.attribs);
} else if (node.type == "text") {
nativeElement = new ReactNativeElement("rawtext", {text:node.data});
}
if (DOM.hasClass(node, NG_BINDING_CLASS)) {
boundElements.push(nativeElement);
}
//create and then attach children
if (node.children && node.name != "template") {
var children = this._dfsAndCreateNativeElements(node.children, boundElements);
for (var j = 0; j < children.length; j++) {
var child = children[j];
nativeElement.insertChildAtIndex(child, j);
}
}
resultingNativeChildren.push(nativeElement)
}
return resultingNativeChildren;
}
示例7: expect
tb.createView(TestComponent, {html: html}).then((view) => {
view.detectChanges();
DOM.addClass(view.nodes[0].childNodes[1], "foo");
view.context.numberCondition = 2;
view.detectChanges();
expect(DOM.hasClass(view.nodes[0].childNodes[1], "foo")).toBe(true);
async.done();
});
示例8: constructor
constructor({elementBinders,
element,
isRootView}) {
this.element = element;
this.elementBinders = elementBinders;
this.isTemplateElement = DOM.isTemplateElement(this.element);
this.isRootView = isRootView;
this.rootBindingOffset = (isPresent(this.element) && DOM.hasClass(this.element, NG_BINDING_CLASS)) ? 1 : 0;
}