当前位置: 首页>>代码示例>>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;未经允许,请勿转载。