當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript BrowserDomAdapter.makeCurrent方法代碼示例

本文整理匯總了TypeScript中@angular/platform-browser/src/browser/browser_adapter.BrowserDomAdapter.makeCurrent方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript BrowserDomAdapter.makeCurrent方法的具體用法?TypeScript BrowserDomAdapter.makeCurrent怎麽用?TypeScript BrowserDomAdapter.makeCurrent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@angular/platform-browser/src/browser/browser_adapter.BrowserDomAdapter的用法示例。


在下文中一共展示了BrowserDomAdapter.makeCurrent方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: init

  function init() {
    BrowserDomAdapter.makeCurrent();
    const tree = document.createElement('tree');
    document.querySelector('baseline').appendChild(tree);
    app = new BaseLineTreeComponent(tree);

    bindAction('#destroyDom', destroyDom);
    bindAction('#createDom', createDom);

    bindAction('#updateDomProfile', profile(createDom, noop, 'baseline-update'));
    bindAction('#createDomProfile', profile(createDom, destroyDom, 'baseline-create'));
  }
開發者ID:xavier268,項目名稱:angular,代碼行數:12,代碼來源:index.ts

示例2: 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:0xJoKe,項目名稱:angular,代碼行數:46,代碼來源:selector_benchmark.ts

示例3: DomService

export function DomService() {
    BrowserDomAdapter.makeCurrent();
    return getDOM();
}
開發者ID:RandyBoy,項目名稱:new-router,代碼行數:4,代碼來源:dom-service.ts

示例4: 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 = ReflectiveInjector.resolveAndCreate(bindings);

  var D_KEY = ReflectiveKey.get(D);
  var E_KEY = ReflectiveKey.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 = ReflectiveInjector.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) {
      ReflectiveInjector.resolveAndCreate(variousProviders);
    }
  }

  /**
   * Same as [createVariety] but resolves providers ahead of time.
   */
  function createVarietyResolved() {
    for (var i = 0; i < iterations; ++i) {
      ReflectiveInjector.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:JanStureNielsen,項目名稱:angular,代碼行數:75,代碼來源:di_benchmark.ts


注:本文中的@angular/platform-browser/src/browser/browser_adapter.BrowserDomAdapter.makeCurrent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。