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

TypeScript kernel.PLATFORM类代码示例

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

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



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

示例1: bindLetElement

  private bindLetElement(parentManifest: IElementSymbol, node: HTMLElement): void {
    const symbol = new LetElementSymbol(this.dom, node);
    parentManifest.childNodes.push(symbol);

    const attributes = node.attributes;
    let i = 0;
    while (i < attributes.length) {
      const attr = attributes[i];
      if (attr.name === 'to-view-model') {
        node.removeAttribute('to-view-model');
        symbol.toViewModel = true;
        continue;
      }
      const attrSyntax = this.attrParser.parse(attr.name, attr.value);
      const command = this.resources.getBindingCommand(attrSyntax);
      const bindingType = command === null ? BindingType.Interpolation : command.bindingType;
      const expr = this.exprParser.parse(attrSyntax.rawValue, bindingType);
      const to = PLATFORM.camelCase(attrSyntax.target);
      const info = new BindableInfo(to, BindingMode.toView);
      symbol.bindings.push(new BindingSymbol(command, info, expr, attrSyntax.rawValue, to));

      ++i;
    }
    node.parentNode.replaceChild(symbol.marker as Node, node);
  }
开发者ID:aurelia,项目名称:aurelia,代码行数:25,代码来源:template-binder.ts


示例2: createElementInfo

function createElementInfo(def: TemplateDefinition): ElementInfo {
  const info = new ElementInfo(def.name, def.containerless);
  const bindables = def.bindables;
  const defaultBindingMode = BindingMode.toView;

  let bindable: IBindableDescription;
  let prop: string;
  let attr: string;
  let mode: BindingMode;

  for (prop in bindables) {
    bindable = bindables[prop];
    // explicitly provided property name has priority over the implicit property name
    if (bindable.property !== undefined) {
      prop = bindable.property;
    }
    // explicitly provided attribute name has priority over the derived implicit attribute name
    if (bindable.attribute !== undefined) {
      attr = bindable.attribute;
    } else {
      // derive the attribute name from the resolved property name
      attr = PLATFORM.kebabCase(prop);
    }
    if (bindable.mode !== undefined && bindable.mode !== BindingMode.default) {
      mode = bindable.mode;
    } else {
      mode = defaultBindingMode;
    }
    info.bindables[attr] = new BindableInfo(prop, mode);
  }
  return info;
}
开发者ID:aurelia,项目名称:aurelia,代码行数:32,代码来源:resource-model.ts


示例3: verifyCalled

 PLATFORM.requestAnimationFrame(() => {
   obj1.foo = obj2.foo = `${++frameCount + 1}`;
   verifyCalled(7);
   PLATFORM.requestAnimationFrame(() => {
     obj1.foo = obj2.foo = `${++frameCount + 1}`;
     verifyCalled(8);
     PLATFORM.requestAnimationFrame(() => {
       obj1.foo = obj2.foo = `${++frameCount + 1}`;
       verifyCalled(9);
       PLATFORM.requestAnimationFrame(() => {
         obj1.foo = obj2.foo = `${++frameCount + 1}`;
         verifyCalled(10);
         PLATFORM.requestAnimationFrame(() => {
           obj1.foo = obj2.foo = `${++frameCount + 1}`;
           verifyCalled(11);
           observer1.unsubscribe(subscriber1);
           observer1.unsubscribe(subscriber2);
           observer2.unsubscribe(subscriber3);
           observer2.unsubscribe(subscriber4);
           done();
         });
       });
     });
   });
 });
开发者ID:aurelia,项目名称:aurelia,代码行数:25,代码来源:dirty-checker.spec.ts


示例4: expect

 PLATFORM.requestAnimationFrame(() => {
   expect(callCount).to.equal(0);
   PLATFORM.requestAnimationFrame(() => {
     expect(callCount).to.equal(0);
     observer.unsubscribe(subscriber);
     done();
   });
 });
开发者ID:aurelia,项目名称:aurelia,代码行数:8,代码来源:dirty-checker.spec.ts


示例5: getTarget

export function getTarget(binding: PlainAttributeSymbol | BindingSymbol, camelCase: boolean): string {
  if (binding.flags & SymbolFlags.isBinding) {
    return (binding as BindingSymbol).bindable.propName;
  } else if (camelCase) {
    return PLATFORM.camelCase((binding as PlainAttributeSymbol).syntax.target);
  } else {
    return (binding as PlainAttributeSymbol).syntax.target;
  }
}
开发者ID:aurelia,项目名称:aurelia,代码行数:9,代码来源:binding-command.ts


示例6: constructor

  constructor(dom: IDOM<Node>, $customElement: ICustomElement<Node>, host: Node) {
    if (host.childNodes.length) {
      this.childNodes = PLATFORM.toArray(host.childNodes);
    } else {
      this.childNodes = PLATFORM.emptyArray;
    }

    this.host = dom.convertToRenderLocation(host) as CustomElementHost<Node>;
    this.host.$customElement = $customElement;
  }
开发者ID:aurelia,项目名称:aurelia,代码行数:10,代码来源:projectors.ts


示例7: getAttributeInfo

 /**
  * Retrieve information about a custom attribute resource.
  *
  * @param syntax The parsed `AttrSyntax`
  *
  * @returns The resource information if the attribute exists, or `null` if it does not exist.
  */
 public getAttributeInfo(syntax: AttrSyntax): AttrInfo | null {
   const name = PLATFORM.camelCase(syntax.target);
   let result = this.attributeLookup[name];
   if (result === undefined) {
     const def = this.resources.find(CustomAttributeResource, name);
     if (def === null) {
       result = null;
     } else {
       result = createAttributeInfo(def);
     }
     this.attributeLookup[name] = result;
   }
   return result;
 }
开发者ID:aurelia,项目名称:aurelia,代码行数:21,代码来源:resource-model.ts


示例8: it

  it('does nothing if disabled', function(done) {
    const framesPerCheck: number = 1;
    DirtyCheckSettings.framesPerCheck = framesPerCheck;
    DirtyCheckSettings.disabled = true;
    const { dirtyChecker } = setup();

    const obj = { foo: '0' };
    const observer = dirtyChecker.createProperty(obj, 'foo');

    let callCount: number = 0;
    const subscriber = {
      handleChange() {
        ++callCount;
      }
    };

    observer.subscribe(subscriber);

    obj.foo = `1`;

    expect(callCount).to.equal(0);

    PLATFORM.requestAnimationFrame(() => {
      expect(callCount).to.equal(0);
      PLATFORM.requestAnimationFrame(() => {
        expect(callCount).to.equal(0);
        PLATFORM.requestAnimationFrame(() => {
          expect(callCount).to.equal(0);
          PLATFORM.requestAnimationFrame(() => {
            expect(callCount).to.equal(0);
            PLATFORM.requestAnimationFrame(() => {
              expect(callCount).to.equal(0);
              observer.unsubscribe(subscriber);
              done();
            });
          });
        });
      });
    });
  });
开发者ID:aurelia,项目名称:aurelia,代码行数:40,代码来源:dirty-checker.spec.ts


示例9: it

    it('is still true when a request is still in progress', function(done) {
      const firstResponse = emptyResponse(200);
      const secondResponse = new Promise((resolve) => {
        PLATFORM.setTimeout(() => { resolve(emptyResponse(200)); }, 200);
      });

      fetch.onCall(0).returns(firstResponse);
      fetch.onCall(1).returns(secondResponse);
      expect(client.isRequesting, 'Before start').to.equal(false);

      const request1 = client.fetch('http://example.com/some/cool/path');
      const request2 = client.fetch('http://example.com/some/cool/path');
      expect(client.isRequesting, 'When started').to.equal(true);
      request1.then(() => {
        expect(client.isRequesting, 'When request 1 is completed').to.equal(true);
      }).catch(() => { done('Unexpected catch'); });
      PLATFORM.setTimeout(() => { expect(client.isRequesting, 'After 100ms').to.equal(true); }, 100);
      request2.then(() => {
        expect(client.isRequesting, 'When all requests are finished').to.equal(false);
      }).then(() => {
        expect(fetch).to.have.callCount(2);
        done();
      }).catch(() => { done('Unexpected catch'); });
    });
开发者ID:aurelia,项目名称:aurelia,代码行数:24,代码来源:http-client.spec.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript kernel.PLATFORM.global类代码示例发布时间:2022-05-28
下一篇:
TypeScript kernel.IServiceLocator类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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