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


TypeScript kernel.PLATFORM類代碼示例

本文整理匯總了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;未經允許,請勿轉載。