本文整理汇总了TypeScript中angular2/src/dom/dom_adapter.DOM.getStyle方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DOM.getStyle方法的具体用法?TypeScript DOM.getStyle怎么用?TypeScript DOM.getStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/src/dom/dom_adapter.DOM
的用法示例。
在下文中一共展示了DOM.getStyle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should set and remove styles', () => {
view.setElementStyle(0, 'width', '40px');
expect(DOM.getStyle(el, 'width')).toEqual('40px');
view.setElementStyle(0, 'width', null);
expect(DOM.getStyle(el, 'width')).toEqual('');
});
示例2: it
it('should return a setter for a style with a unit', () => {
var setterFn = setterFactory('style.height.px');
setterFn(div, 40);
expect(DOM.getStyle(div, 'height')).toEqual('40px');
setterFn(div, null);
expect(DOM.getStyle(div, 'height')).toEqual('');
var otherSetterFn = setterFactory('style.height.px');
expect(setterFn).toBe(otherSetterFn);
});
示例3: it
it('should de-normalize style names', () => {
var setterFn = setterFactory.createSetter(div, false, 'style.textAlign');
setterFn(div, 'right');
expect(DOM.getStyle(div, 'text-align')).toEqual('right');
setterFn(div, null);
expect(DOM.getStyle(div, 'text-align')).toEqual('');
var otherSetterFn = setterFactory.createSetter(div, false, 'style.textAlign');
expect(setterFn).toBe(otherSetterFn);
});
示例4: it
it('should be injectable and callable', () => {
var div = el('<div></div>');
var ngElement = new NgElement(div);
var preBuildObject = new PreBuiltObjects(null, ngElement, null, null);
var inj = injector([NeedsPropertySetter], null, null, preBuildObject);
var component = inj.get(NeedsPropertySetter);
component.setProp('foobar');
component.setRole('button');
component.setClass(true);
component.classWithDashSetter(true);
component.setStyle('40px');
component.setStyleWithUnit(50);
expect(div.title).toEqual('foobar');
expect(DOM.getAttribute(div, 'role')).toEqual('button');
expect(DOM.hasClass(div, 'active')).toEqual(true);
expect(DOM.hasClass(div, 'foo-bar')).toEqual(true);
expect(DOM.getStyle(div, 'width')).toEqual('40px');
expect(DOM.getStyle(div, 'height')).toEqual('50px');
});