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


TypeScript DOM.getAttribute方法代码示例

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


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

示例1: fakeAsync

         fakeAsync(inject([Router, TestComponentBuilder], (router, tcb) => {
           let fixture = tcb.createFakeAsync(RootCmp);
           advance(fixture);

           router.navigateByUrl('/team/22/link(simple)');
           advance(fixture);
           expect(fixture.debugElement.nativeElement).toHaveText('team 22 { link, aux: simple }');

           let native = DOM.querySelector(fixture.debugElement.nativeElement, "a");
           expect(DOM.getAttribute(native, "href")).toEqual("/team/33/simple(aux:simple)");

           router.navigateByUrl('/team/22/link(simple2)');
           advance(fixture);

           expect(DOM.getAttribute(native, "href")).toEqual("/team/33/simple(aux:simple2)");
         })));
开发者ID:davewragg,项目名称:angular,代码行数:16,代码来源:integration_spec.ts

示例2: expect

 .then((testComponent) => {
   testComponent.detectChanges();
   let anchorElement =
       testComponent.debugElement.query(By.css('a.detail-view')).nativeElement;
   expect(DOM.getAttribute(anchorElement, 'href')).toEqual('detail');
   async.done();
 });
开发者ID:ChinnasamyM,项目名称:angular,代码行数:7,代码来源:router_link_spec.ts

示例3: 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:844496869,项目名称:angular,代码行数:10,代码来源:selector_spec.ts

示例4: ripple

  /**
   * Apply an ink ripple to an element at the given position.
   *
   * @param element The element to apply a ripple to
   * @param x The x position inside the element for the ripple to originate from
   * @param y The y position inside the element for the ripple to originate from
   * @returns {Promise<any>} A promise that resolves when the ripple has faded
   */
  static ripple(element: HTMLElement, x: number, y: number): Promise<any> {
    let fit: boolean = isPresent(DOM.getAttribute(element, 'md-fab'));

    let container = DOM.createElement('div');
    DOM.addClass(container, 'md-ripple-container');

    let ripple = DOM.createElement('div');
    DOM.addClass(ripple, 'md-ripple');
    DOM.appendChild(container, ripple);

    DOM.appendChild(element, container);

    let getHostSize = () => {
      let elX = element.offsetWidth;
      let elY = element.offsetHeight;
      return Ink.getSize(fit, elX, elY);
    };
    let getInitialStyles = (): any => {
      let size = getHostSize();
      let color = DOM.getComputedStyle(element).color || 'rgb(0,0,0)';
      return {
        'background-color': color,
        left: `${x - size / 2}px`,
        top: `${y - size / 2}px`,
        width: `${size}px`,
        height: `${size}px`,
        opacity: 0.2,
        transform: 'scale(0.01)'
      };
    };

    return Animate.setStyles(ripple, getInitialStyles())
      .then(() => Animate.animateStyles(ripple, {
        left: '50%',
        top: '50%',
        opacity: 0.1,
        transform: 'translate(-50%, -50%) scale(1)'
      }, 450))
      .then(() => Animate.animateStyles(ripple, {opacity: 0}, 650))
      .then(() => DOM.removeChild(element, container));
  }
开发者ID:AEKurt,项目名称:ng2-material,代码行数:49,代码来源:ink.ts

示例5: 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);

    });
开发者ID:kreo,项目名称:angular-2-bootstraping,代码行数:21,代码来源:dom_adapter_spec.ts

示例6: ripple

  /**
   * Apply an ink ripple to an element at the given position.
   *
   * @param element The element to apply a ripple to
   * @param left The x position inside the element for the ripple to originate from
   * @param top The y position inside the element for the ripple to originate from
   * @returns {Promise<any>} A promise that resolves when the ripple has faded
   */
  static ripple(element: HTMLElement, left: number, top: number): Promise<any> {
    let fit: boolean = isPresent(DOM.getAttribute(element, 'md-fab'));

    let container = DOM.querySelector(element, '.md-ripple-container');
    if (!container) {
      container = DOM.createElement('div');
      DOM.addClass(container, 'md-ripple-container');
      DOM.appendChild(element, container);
    }

    let ripple = DOM.createElement('div');
    DOM.addClass(ripple, 'md-ripple');

    let getInitialStyles = (): any => {
      let color = DOM.getComputedStyle(element).color || 'rgb(0,0,0)';
      let size = Ink.getSize(fit, element.clientWidth, element.clientHeight);
      return {
        'background-color': color,
        left: `${left}px`,
        top: `${top}px`,
        width: `${size}px`,
        height: `${size}px`
      };
    };

    return Animate.setStyles(ripple, getInitialStyles())
      .then(() => DOM.appendChild(container, ripple))
      .then(() => DOM.addClass(ripple, 'md-ripple-placed'))
      .then(() => Animate.wait())
      .then(() => DOM.addClass(ripple, 'md-ripple-scaled'))
      .then(() => DOM.addClass(ripple, 'md-ripple-active'))
      .then(() => Animate.wait(450))
      .then(() => DOM.removeClass(ripple, 'md-ripple-active'))
      .then(() => Animate.wait(650))
      .then(() => DOM.removeChild(container, ripple));
  }
开发者ID:790,项目名称:ng2-material,代码行数:44,代码来源:ink.ts

示例7: getHref

export function getHref(elt) {
  return DOM.getAttribute(elt, 'href');
}
开发者ID:844496869,项目名称:angular,代码行数:3,代码来源:util.ts


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