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


TypeScript dom_adapter.DOM类代码示例

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


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

示例1: it

        it('should return the value of the base element', () => {
          var baseEl = DOM.createElement('base');
          DOM.setAttribute(baseEl, 'href', '/drop/bass/connon/');
          var headEl = DOM.defaultDoc().head;
          DOM.appendChild(headEl, baseEl);

          var baseHref = DOM.getBaseHref();
          DOM.removeChild(headEl, baseEl);
          DOM.resetBaseElement();

          expect(baseHref).toEqual('/drop/bass/connon/');
        });
开发者ID:Ashok-Pal,项目名称:angular,代码行数:12,代码来源:dom_adapter_spec.ts

示例2: it

        it('should return a relative url', () => {
          var baseEl = DOM.createElement('base');
          DOM.setAttribute(baseEl, 'href', 'base');
          var headEl = DOM.defaultDoc().head;
          DOM.appendChild(headEl, baseEl);

          var baseHref = DOM.getBaseHref();
          DOM.removeChild(headEl, baseEl);
          DOM.resetBaseElement();

          expect(baseHref.endsWith('/base')).toBe(true);
        });
开发者ID:LordBinary,项目名称:angular,代码行数:12,代码来源:dom_adapter_spec.ts

示例3: it

 it('deletes micropost when confirmed', done => {
   const cmp:Feed = cmpDebugElement.componentInstance;
   const testCmp:TestCmp = ctx.fixture.debugElement.componentInstance;
   const deleteLink = DOM.querySelector(cmpDebugElement.nativeElement, '.delete');
   spyOn(window, 'confirm').and.returnValue(true);
   spyOn(cmp, 'list');
   spyOn(testCmp, 'listenDeleted');
   ObservableWrapper.subscribe(cmp.deleted, () => {
     expect(cmp.list).toHaveBeenCalled();
     expect(testCmp.listenDeleted).toHaveBeenCalled();
     done();
   });
   deleteLink.click();
 });
开发者ID:windwang,项目名称:angular2-app,代码行数:14,代码来源:Feed.spec.ts

示例4: main

export function main() {
  var typedComponentFactory = typed.CompANgFactory;
  var untypedComponentFactory = untyped.CompANgFactory;
  var fixtures: TestFixture[] = [];

  if (IS_DART || !DOM.supportsDOMEvents()) {
    // Our generator only works on node.js and Dart...
    fixtures.push(new TestFixture(typedComponentFactory, 'typed'));
  }
  if (!IS_DART) {
    // Our generator only works on node.js and Dart...
    if (!DOM.supportsDOMEvents()) {
      fixtures.push(new TestFixture(untypedComponentFactory, 'untyped'));
    }
  }
  describe('OfflineCompiler', () => {
    var injector: Injector;
    var sharedStylesHost: SharedStylesHost;

    beforeEach(inject([Injector, SharedStylesHost], (_injector, _sharedStylesHost) => {
      injector = _injector;
      sharedStylesHost = _sharedStylesHost;
    }));

    fixtures.forEach((fixture) => {
      describe(`${fixture.name}`, () => {
        it('should compile components', () => {
          var hostEl = fixture.compFactory.create(injector);
          expect(hostEl.instance).toBeAnInstanceOf(CompA);
          var styles = sharedStylesHost.getAllStyles();
          expect(styles[0]).toContain('.redStyle[_ngcontent');
          expect(styles[1]).toContain('.greenStyle[_ngcontent');
        });
      });
    });
  });
}
开发者ID:JavaScript-Resource,项目名称:angular,代码行数:37,代码来源:offline_compiler_spec.ts

示例5: it

  it('can be shown', () => {
    expect(cmpDebugElement).toBeTruthy();

    const cmp:UserStats = cmpDebugElement.componentInstance;
    expect(cmp.userId).toEqual('1');
    expect(cmp.user).toBeTruthy();
    expect(cmp.user.id).toEqual(1);
    expect(cmp.user.email).toEqual('test1@test.com');
    expect(cmp.user.userStats.micropostCnt).toEqual(2);

    const gravatarDebugElement = cmpDebugElement.query(By.directive(Gravatar));
    expect(gravatarDebugElement).toBeTruthy();
    expect(gravatarDebugElement.componentInstance.email).toEqual('test1@test.com');
    expect(gravatarDebugElement.componentInstance.alt).toEqual('test1');

    const el = cmpDebugElement.nativeElement;
    const header = DOM.querySelector(el, 'h2');
    expect(header.innerText).toMatch(/test1/);

    const profileLink = DOM.querySelector(el, 'a.profile-link');
    expect(profileLink).toBeTruthy();
    expect(profileLink.getAttribute('href')).toEqual('/users/1');

    const postCnt = DOM.querySelector(el, '.microposts');
    expect(postCnt).toBeTruthy();
    expect(postCnt.innerText).toMatch(/2 microposts/);

    const followingsLink = DOM.querySelector(el, 'a.followings');
    expect(followingsLink).toBeTruthy();
    expect(followingsLink.getAttribute('href')).toEqual('/users/1/followings');
    expect(followingsLink.innerText).toMatch(/3[\s\S]*?followings/);

    const followersLink = DOM.querySelector(el, 'a.followers');
    expect(followersLink).toBeTruthy();
    expect(followersLink.getAttribute('href')).toEqual('/users/1/followers');
    expect(followersLink.innerText).toMatch(/4[\s\S]*?followers/);
  });
开发者ID:gtostock,项目名称:angular2-app,代码行数:37,代码来源:UserStats.spec.ts

示例6: setup

        return setup(template).then((fixture: ComponentFixture) => {
          let element: DebugElement = fixture.debugElement.query(By.css('[md-ink]'));
          let save = Ink.rippleEvent;
          let fired = false;
          Ink.rippleEvent = () => {
            fired = true;
            return Promise.resolve();
          };

          let event = DOM.createEvent('mouse');
          element.triggerEventHandler('mousedown', event);

          expect(fired).toBe(false);
          Ink.rippleEvent = save;
        });
开发者ID:LiTiang,项目名称:ng2-material,代码行数:15,代码来源:ink_spec.ts

示例7:

 .then(rootTC => {
   rootTC.detectChanges();
   let appDOMEl = rootTC.debugElement.children[0].nativeElement;
   t.e(DOM.querySelectorAll(appDOMEl, 'form > select option').length).toBe(5);
   t.e(DOM.querySelectorAll(appDOMEl, 'form > select option')[0].value).toBe('en');
   t.e(DOM.querySelectorAll(appDOMEl, 'form > select option')[1].value).toBe('es');
   t.e(DOM.querySelectorAll(appDOMEl, 'form > select option')[2].value).toBe('fr');
   t.e(DOM.querySelectorAll(appDOMEl, 'form > select option')[3].value).toBe('ru');
   t.e(DOM.querySelectorAll(appDOMEl, 'form > select option')[4].value).toBe('bg');
 });
开发者ID:QuinntyneBrown,项目名称:angular2-seed-advanced,代码行数:10,代码来源:lang-switcher.component.spec.ts

示例8: _injectorProviders

// TODO: This code is nearly identical to core/application. There should be a way to only write it
// once
function _injectorProviders(): any[] {
  return [
    provide(DOCUMENT, {useValue: DOM.defaultDoc()}),
    EventManager,
    new Provider(EVENT_MANAGER_PLUGINS, {useClass: DomEventsPlugin, multi: true}),
    new Provider(EVENT_MANAGER_PLUGINS, {useClass: KeyEventsPlugin, multi: true}),
    new Provider(EVENT_MANAGER_PLUGINS, {useClass: HammerGesturesPlugin, multi: true}),
    provide(DomRenderer, {useClass: DomRenderer_}),
    provide(Renderer, {useExisting: DomRenderer}),
    APP_ID_RANDOM_PROVIDER,
    DomSharedStylesHost,
    provide(SharedStylesHost, {useExisting: DomSharedStylesHost}),
    Serializer,
    provide(ON_WEB_WORKER, {useValue: false}),
    provide(ElementSchemaRegistry, {useValue: new DomElementSchemaRegistry()}),
    RenderViewWithFragmentsStore,
    RenderProtoViewRefStore,
    AppViewPool,
    provide(APP_VIEW_POOL_CAPACITY, {useValue: 10000}),
    provide(AppViewManager, {useClass: AppViewManager_}),
    AppViewManagerUtils,
    AppViewListener,
    ProtoViewFactory,
    ViewResolver,
    provide(PLATFORM_PIPES, {useValue: COMMON_PIPES, multi: true}),
    provide(PLATFORM_DIRECTIVES, {useValue: COMMON_DIRECTIVES, multi: true}),
    DirectiveResolver,
    Parser,
    Lexer,
    provide(ExceptionHandler, {useFactory: () => new ExceptionHandler(DOM), deps: []}),
    provide(XHR, {useValue: new XHRImpl()}),
    UrlResolver,
    provide(DynamicComponentLoader, {useClass: DynamicComponentLoader_}),
    Testability,
    AnchorBasedAppRootUrl,
    provide(AppRootUrl, {useExisting: AnchorBasedAppRootUrl}),
    WebWorkerApplication,
    WebWorkerSetup,
    MessageBasedXHRImpl,
    MessageBasedRenderer,
    provide(ServiceMessageBrokerFactory, {useClass: ServiceMessageBrokerFactory_}),
    provide(ClientMessageBrokerFactory, {useClass: ClientMessageBrokerFactory_}),
    BrowserDetails,
    AnimationBuilder
  ];
}
开发者ID:kreo,项目名称:angular-2-bootstraping,代码行数:48,代码来源:di_bindings.ts

示例9: it

    it('should support duration and delay', inject([AnimationBuilder], (animate) => {
         var animateCss = animate.css();
         animateCss.setDelay(100).setDuration(200);
         expect(animateCss.data.duration).toBe(200);
         expect(animateCss.data.delay).toBe(100);

         var element = el('<div></div>');
         var runner = animateCss.start(element);
         runner.flush();

         if (DOM.supportsAnimation()) {
           expect(runner.computedDelay).toBe(100);
           expect(runner.computedDuration).toBe(200);
         } else {
           expect(runner.computedDelay).toBe(0);
           expect(runner.computedDuration).toBe(0);
         }
       }));
开发者ID:LordBinary,项目名称:angular,代码行数:18,代码来源:animation_builder_spec.ts

示例10: it

  it('can be shown', () => {
    ctx.fixture.detectChanges();

    expect(cmpDebugElement).toBeTruthy();

    const cmp:UserList = cmpDebugElement.componentInstance;
    expect(cmp.users.length).toEqual(2);

    expect(DOM.querySelectorAll(cmpDebugElement.nativeElement, '.users>li').length).toEqual(2);

    const gravatarDebugElement = cmpDebugElement.query(By.directive(Gravatar));
    expect(gravatarDebugElement).toBeTruthy();
    expect(gravatarDebugElement.componentInstance.alt).toEqual('test1');
    expect(gravatarDebugElement.componentInstance.email).toEqual('test1@test.com');

    const userLink:HTMLElement = cmpDebugElement.query(By.css('.users>li>a')).nativeElement;
    expect(userLink.innerText).toEqual('test1');
    expect(userLink.getAttribute('href')).toEqual('/users/1');
  });
开发者ID:gtostock,项目名称:angular2-app,代码行数:19,代码来源:UserList.spec.ts


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