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


TypeScript runtime.ILifecycle類代碼示例

本文整理匯總了TypeScript中@aurelia/runtime.ILifecycle的典型用法代碼示例。如果您正苦於以下問題:TypeScript ILifecycle類的具體用法?TypeScript ILifecycle怎麽用?TypeScript ILifecycle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: describe

describe('ClassAccessor', function () {
  let sut: ClassAttributeAccessor;
  let el: HTMLElement;
  let lifecycle: ILifecycle;
  let initialClassList: string;

  const markupArr = [
    '<div></div>',
    '<div class=""></div>',
    '<div class="foo"></div>',
    '<div class="foo bar baz"></div>'
  ];
  const classListArr = ['', 'foo', 'foo bar', 'bar baz', 'qux', 'bar qux', 'qux quux'];
  const secondClassListArr = ['', 'fooo'];
  for (const markup of markupArr) {
    for (const classList of classListArr) {
      beforeEach(function () {
        const ctx = TestContext.createHTMLTestContext();
        el = ctx.createElementFromMarkup(markup);
        initialClassList = el.classList.toString();
        const { lifecycle: $lifecycle } = setup();
        lifecycle = $lifecycle;
        sut = new ClassAttributeAccessor(lifecycle, el);
      });

      it(`setValue("${classList}") updates ${markup}`, function () {
        sut.setValue(classList, LifecycleFlags.none);
        expect(el.classList.toString()).to.equal(initialClassList);
        lifecycle.processFlushQueue(LifecycleFlags.none);
        const updatedClassList = el.classList.toString();
        for (const cls of initialClassList.split(' ')) {
          expect(updatedClassList).to.contain(cls);
        }
        for (const cls of classList.split(' ')) {
          expect(updatedClassList).to.contain(cls);
        }
      });

      for (const secondClassList of secondClassListArr) {
        it(`setValue("${secondClassList}") updates already-updated ${markup}`, function () {
          sut.setValue(classList, LifecycleFlags.none);
          lifecycle.processFlushQueue(LifecycleFlags.none);
          const updatedClassList = el.classList.toString();
          sut.setValue(secondClassList, LifecycleFlags.none);
          expect(el.classList.toString()).to.equal(updatedClassList);
          lifecycle.processFlushQueue(LifecycleFlags.none);
          const secondUpdatedClassList = el.classList.toString();
          for (const cls of initialClassList.split(' ')) {
            if (!classList.includes(cls)) {
              expect(secondUpdatedClassList).to.contain(cls);
            }
          }
          for (const cls of secondClassList.split(' ')) {
            expect(secondUpdatedClassList).to.contain(cls);
          }
        });
      }
    }
  }
});
開發者ID:aurelia,項目名稱:aurelia,代碼行數:60,代碼來源:target-observers.spec.ts

示例2: it

 it(`setValue("${secondClassList}") updates already-updated ${markup}`, function () {
   sut.setValue(classList, LifecycleFlags.none);
   lifecycle.processFlushQueue(LifecycleFlags.none);
   const updatedClassList = el.classList.toString();
   sut.setValue(secondClassList, LifecycleFlags.none);
   expect(el.classList.toString()).to.equal(updatedClassList);
   lifecycle.processFlushQueue(LifecycleFlags.none);
   const secondUpdatedClassList = el.classList.toString();
   for (const cls of initialClassList.split(' ')) {
     if (!classList.includes(cls)) {
       expect(secondUpdatedClassList).to.contain(cls);
     }
   }
   for (const cls of secondClassList.split(' ')) {
     expect(secondUpdatedClassList).to.contain(cls);
   }
 });
開發者ID:aurelia,項目名稱:aurelia,代碼行數:17,代碼來源:target-observers.spec.ts

示例3:

 public $detach(): void {
   this.$lifecycle.enqueueUnmount(this);
   this.$state &= ~State.isAttached;
 }
開發者ID:aurelia,項目名稱:aurelia,代碼行數:4,代碼來源:fake-view.ts


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