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


TypeScript DOM.getAttribute方法代码示例

本文整理汇总了TypeScript中angular2/src/dom/dom_adapter.DOM.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DOM.getAttribute方法的具体用法?TypeScript DOM.getAttribute怎么用?TypeScript DOM.getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular2/src/dom/dom_adapter.DOM的用法示例。


在下文中一共展示了DOM.getAttribute方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: logEntry

function logEntry(log: string[], parent, current) {
  var parentId = '';
  if (isPresent(parent)) {
    parentId = DOM.getAttribute(parent.element, 'id') + '<';
  }
  log.push(parentId + DOM.getAttribute(current.element, 'id'));
}
开发者ID:AsherBarak,项目名称:angular,代码行数:7,代码来源:pipeline_spec.ts

示例2: logEntry

function logEntry(log, parent, current) {
  var parentId = '';
  if (isPresent(parent)) {
    parentId = DOM.getAttribute(parent.element, 'id') + '<';
  }
  ListWrapper.push(log, parentId + DOM.getAttribute(current.element, 'id'));
}
开发者ID:CADBOT,项目名称:angular,代码行数:7,代码来源:pipeline_spec.ts

示例3: it

    it('should not set host element attribute if an attribute already exists', () => {
      var element = el('<input attr_name="initial" some-decor-with-host-attrs>');
      var results = process(element);

      expect(DOM.getAttribute(results[0].element, 'attr_name')).toEqual('initial');

      DOM.removeAttribute(element, 'attr_name');
      results = process(element);
      expect(DOM.getAttribute(results[0].element, 'attr_name')).toEqual('attr_val');
    });
开发者ID:lavinjj,项目名称:angular,代码行数:10,代码来源:directive_parser_spec.ts

示例4: createView

 compiler.compile(MyComp).then((pv) => {
   createView(pv);
   ctx.ctxProp = 'Initial aria label';
   cd.detectChanges();
   expect(DOM.getAttribute(view.nodes[0], 'aria-label')).toEqual('Initial aria label');
   ctx.ctxProp = 'Changed aria label';
   cd.detectChanges();
   expect(DOM.getAttribute(view.nodes[0], 'aria-label')).toEqual('Changed aria label');
   async.done();
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:10,代码来源:integration_spec.ts

示例5: it

    it('should return a setter for an attribute', () => {
      var setterFn = setterFactory.createSetter(div, false, 'attr.role');
      setterFn(div, 'button');
      expect(DOM.getAttribute(div, 'role')).toEqual('button');
      setterFn(div, null);
      expect(DOM.getAttribute(div, 'role')).toEqual(null);
      expect(() => { setterFn(div, 4); })
          .toThrowError("Invalid role attribute, only string values are allowed, got '4'");

      var otherSetterFn = setterFactory.createSetter(div, false, 'attr.role');
      expect(setterFn).toBe(otherSetterFn);
    });
开发者ID:B-Thapa,项目名称:angular,代码行数:12,代码来源:property_setter_factory_spec.ts

示例6: it

 it('should collect the root node in the ProtoView element', () => {
   var pv = new ProtoView(templateAwareCreateElement('<div id="1"></div>'), new DynamicProtoChangeDetector(null, null), null);
   var view = pv.instantiate(null, null);
   view.hydrate(null, null, null, null, null);
   expect(view.nodes.length).toBe(1);
   expect(DOM.getAttribute(view.nodes[0], 'id')).toEqual('1');
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:7,代码来源:view_spec.ts

示例7: it

      it('should de-normalize attribute names', () => {
        var setterFn = setterFactory.createSetter(div, false, 'attr.ariaLabel');
        setterFn(div, 'fancy button');
        expect(DOM.getAttribute(div, 'aria-label')).toEqual('fancy button');

        var otherSetterFn = setterFactory.createSetter(div, false, 'attr.ariaLabel');
        expect(setterFn).toBe(otherSetterFn);
      });
开发者ID:AsherBarak,项目名称:angular,代码行数:8,代码来源:property_setter_factory_spec.ts

示例8: it

 it('should select by attr name only once if the value is from the DOM', () => {
   matcher.addSelectables(s1 = CssSelector.parse('[some-decor]'), 1);
   var elementSelector = new CssSelector();
   var element = el('<div attr></div>');
   var empty = DOM.getAttribute(element, 'attr');
   elementSelector.addAttribute('some-decor', empty);
   matcher.match(elementSelector, selectableCollector);
   expect(matched).toEqual([s1[0], 1]);
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:9,代码来源:selector_spec.ts

示例9: MockStep

 return new MockStep((parent, current, control) => {
   var parentCountStr = DOM.getAttribute(current.element, wrapperId);
   if (isPresent(parentCountStr)) {
     var parentCount = NumberWrapper.parseInt(parentCountStr, 10);
     while (parentCount > 0) {
       control.addParent(new CompileElement(el(`<a id="${wrapperId}#${nextElementId++}"></a>`)));
       parentCount--;
     }
   }
   logEntry(log, parent, current);
 });
开发者ID:CADBOT,项目名称:angular,代码行数:11,代码来源:pipeline_spec.ts

示例10: 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');
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:19,代码来源:element_injector_spec.ts


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