• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript browser_adapter.BrowserDomAdapter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main

export function main() {
  BrowserDomAdapter.makeCurrent();
  var iterations = getIntParameter('iterations');

  reflector.reflectionCapabilities = new ReflectionCapabilities();
  var providers = [
    DirectiveProvider.createFromType(A, null),
    DirectiveProvider.createFromType(B, null),
    DirectiveProvider.createFromType(C, null)
  ];
  var proto = ProtoElementInjector.create(null, 0, providers, false, 0, null);
  var elementInjector = proto.instantiate(null);

  function instantiate() {
    for (var i = 0; i < iterations; ++i) {
      var ei = proto.instantiate(null);
      ei.hydrate(null, null, null);
    }
  }

  function hydrate() {
    for (var i = 0; i < iterations; ++i) {
      elementInjector.dehydrate();
      elementInjector.hydrate(null, null, null);
    }
  }

  bindAction('#instantiate', () => microBenchmark('instantiateAvg', iterations, instantiate));
  bindAction('#hydrate', () => microBenchmark('instantiateAvg', iterations, hydrate));
}
开发者ID:mixed,项目名称:angular,代码行数:30,代码来源:element_injector_benchmark.ts


示例2: createInjector

export function createInjector(zone: NgZone, bus: MessageBus): Injector {
  BrowserDomAdapter.makeCurrent();
  _rootProviders.push(provide(NgZone, {useValue: zone}));
  _rootProviders.push(provide(MessageBus, {useValue: bus}));
  var injector: Injector = Injector.resolveAndCreate(_rootProviders);
  return injector.resolveAndCreateChild(_injectorProviders());
}
开发者ID:kreo,项目名称:angular-2-bootstraping,代码行数:7,代码来源:di_bindings.ts


示例3: bootstrapUICommon

export function bootstrapUICommon(bus: MessageBus): WebWorkerApplication {
  BrowserDomAdapter.makeCurrent();
  var zone = createNgZone();
  wtfInit();
  bus.attachToZone(zone);
  return zone.run(() => {
    var injector = createInjector(zone, bus);
    injector.get(MessageBasedRenderer).start();
    injector.get(MessageBasedXHRImpl).start();
    injector.get(WebWorkerSetup).start();
    return injector.get(WebWorkerApplication);
  });
}
开发者ID:kreo,项目名称:angular-2-bootstraping,代码行数:13,代码来源:impl.ts


示例4: main

export function main() {
  BrowserDomAdapter.makeCurrent();
  var count = getIntParameter('selectors');

  var fixedMatcher;
  var fixedSelectorStrings = [];
  var fixedSelectors = [];
  for (var i = 0; i < count; i++) {
    fixedSelectorStrings.push(randomSelector());
  }
  for (var i = 0; i < count; i++) {
    fixedSelectors.push(CssSelector.parse(fixedSelectorStrings[i]));
  }
  fixedMatcher = new SelectorMatcher();
  for (var i = 0; i < count; i++) {
    fixedMatcher.addSelectables(fixedSelectors[i], i);
  }

  function parse() {
    var result = [];
    for (var i = 0; i < count; i++) {
      result.push(CssSelector.parse(fixedSelectorStrings[i]));
    }
    return result;
  }

  function addSelectable() {
    var matcher = new SelectorMatcher();
    for (var i = 0; i < count; i++) {
      matcher.addSelectables(fixedSelectors[i], i);
    }
    return matcher;
  }

  function match() {
    var matchCount = 0;
    for (var i = 0; i < count; i++) {
      fixedMatcher.match(fixedSelectors[i][0], (selector, selected) => { matchCount += selected; });
    }
    return matchCount;
  }

  bindAction('#parse', parse);
  bindAction('#addSelectable', addSelectable);
  bindAction('#match', match);
}
开发者ID:1186792881,项目名称:angular,代码行数:46,代码来源:selector_benchmark.ts


示例5: initBrowserTests

function initBrowserTests() {
  BrowserDomAdapter.makeCurrent();
  BrowserDetection.setup();
}
开发者ID:AwelEshetu,项目名称:angular,代码行数:4,代码来源:browser_static.ts


示例6: setBaseTestProviders

import "reflect-metadata";

import {TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS} from "angular2/platform/testing/browser";
import {BrowserDomAdapter} from "angular2/src/platform/browser/browser_adapter";
import {setBaseTestProviders} from "angular2/testing";

setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS);
BrowserDomAdapter.makeCurrent();

import "./src/angular2-twitter-share-button.component.spec";
开发者ID:laco0416,项目名称:angular2-twitter-share-button,代码行数:10,代码来源:index.spec.ts


示例7: main

export function main() {
  BrowserDomAdapter.makeCurrent();
  var iterations = getIntParameter('iterations');

  // This benchmark does not use bootstrap and needs to create a reflector
  setupReflector();
  var bindings = [A, B, C, D, E];
  var injector = Injector.resolveAndCreate(bindings);

  var D_KEY = Key.get(D);
  var E_KEY = Key.get(E);
  var childInjector = injector.resolveAndCreateChild([])
                          .resolveAndCreateChild([])
                          .resolveAndCreateChild([])
                          .resolveAndCreateChild([])
                          .resolveAndCreateChild([]);

  var variousProviders = [A, provide(B, {useClass: C}), [D, [E]], provide(F, {useValue: 6})];

  var variousProvidersResolved = Injector.resolve(variousProviders);

  function getByToken() {
    for (var i = 0; i < iterations; ++i) {
      injector.get(D);
      injector.get(E);
    }
  }
  function getByKey() {
    for (var i = 0; i < iterations; ++i) {
      injector.get(D_KEY);
      injector.get(E_KEY);
    }
  }

  function getChild() {
    for (var i = 0; i < iterations; ++i) {
      childInjector.get(D);
      childInjector.get(E);
    }
  }

  function instantiate() {
    for (var i = 0; i < iterations; ++i) {
      var child = injector.resolveAndCreateChild([E]);
      child.get(E);
    }
  }

  /**
   * Creates an injector with a variety of provider types.
   */
  function createVariety() {
    for (var i = 0; i < iterations; ++i) {
      Injector.resolveAndCreate(variousProviders);
    }
  }

  /**
   * Same as [createVariety] but resolves providers ahead of time.
   */
  function createVarietyResolved() {
    for (var i = 0; i < iterations; ++i) {
      Injector.fromResolvedProviders(variousProvidersResolved);
    }
  }

  bindAction('#getByToken', () => microBenchmark('injectAvg', iterations, getByToken));
  bindAction('#getByKey', () => microBenchmark('injectAvg', iterations, getByKey));
  bindAction('#getChild', () => microBenchmark('injectAvg', iterations, getChild));
  bindAction('#instantiate', () => microBenchmark('injectAvg', iterations, instantiate));
  bindAction('#createVariety', () => microBenchmark('injectAvg', iterations, createVariety));
  bindAction('#createVarietyResolved',
             () => microBenchmark('injectAvg', iterations, createVarietyResolved));
}
开发者ID:1186792881,项目名称:angular,代码行数:74,代码来源:di_benchmark.ts


示例8: initWebWorkerRenderPlatform

export function initWebWorkerRenderPlatform(): void {
  BrowserDomAdapter.makeCurrent();
  wtfInit();
  BrowserGetTestability.init();
}
开发者ID:5145813,项目名称:angular-electron,代码行数:5,代码来源:electron_renderer_common.ts


示例9: if

    onMouseMove( event )
    {
        let parentRect = this._dom.getBoundingClientRect( this._element.nativeElement );
        let tooltipRect = this._dom.getBoundingClientRect( this._div );
        let x:number;
        let y:number;

        if ( this.data.location === 'bottom' )
        {
            if ( this.data.offset )
            {
                x = event.clientX - parentRect.left - (tooltipRect.width / 2);
                y = event.clientY - parentRect.top + 30;
            }
            else
            {
                x = event.clientX - (tooltipRect.width / 2);
                y = event.clientY + 30;
            }
        }
        else if ( this.data.location === 'right' )
        {
            if ( this.data.offset )
            {
                x = event.clientX - parentRect.left + 30;
                y = event.clientY - parentRect.top - ( tooltipRect.height / 2 );
            }
            else
            {
                x = event.clientX + 30;
                y = event.clientY - ( tooltipRect.height / 2 );
            }
        }

        this._dom.setStyle( this._div, 'top', y + 'px' );
        this._dom.setStyle( this._div, 'left', x + 'px' );
    }
开发者ID:johnarchuletta,项目名称:followings.io,代码行数:37,代码来源:tooltip-directive.ts


示例10: onMouseLeave

 onMouseLeave( event )
 {
     this._dom.setStyle( this._div, 'display', 'none' );
 }
开发者ID:johnarchuletta,项目名称:followings.io,代码行数:4,代码来源:tooltip-directive.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap