当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript DOM.firstChild方法代码示例

本文整理汇总了TypeScript中angular2/src/dom/dom_adapter.DOM.firstChild方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DOM.firstChild方法的具体用法?TypeScript DOM.firstChild怎么用?TypeScript DOM.firstChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular2/src/dom/dom_adapter.DOM的用法示例。


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

示例1: _moveChildNodes

 _moveChildNodes(source, target) {
   var next = DOM.firstChild(source);
   while (isPresent(next)) {
     DOM.appendChild(target, next);
     next = DOM.firstChild(source);
   }
 }
开发者ID:Salim-K,项目名称:angular,代码行数:7,代码来源:view_splitter.ts

示例2: it

 it('should replace the element with an empty <template> element', () => {
   var rootElement = DOM.createTemplate('<span template=""></span>');
   var originalChild = DOM.firstChild(DOM.content(rootElement));
   var results = proceess(rootElement);
   expect(results[0].element).toBe(rootElement);
   expect(stringifyElement(results[0].element))
       .toEqual('<template><template class="ng-binding"></template></template>');
   expect(stringifyElement(results[2].element))
       .toEqual('<template><span template=""></span></template>');
   expect(DOM.firstChild(DOM.content(results[2].element))).toBe(originalChild);
 });
开发者ID:goderbauer,项目名称:angular,代码行数:11,代码来源:view_splitter_spec.ts

示例3: _process

  _process(results, parent: CompileElement, current: CompileElement,
           compilationCtxtDescription: string = '') {
    var additionalChildren = this._control.internalProcess(results, 0, parent, current);

    if (current.compileChildren) {
      var node = DOM.firstChild(DOM.templateAwareRoot(current.element));
      while (isPresent(node)) {
        // compiliation can potentially move the node, so we need to store the
        // next sibling before recursing.
        var nextNode = DOM.nextSibling(node);
        if (DOM.isElementNode(node)) {
          var childCompileElement = new CompileElement(node, compilationCtxtDescription);
          childCompileElement.inheritedProtoView = current.inheritedProtoView;
          childCompileElement.inheritedElementBinder = current.inheritedElementBinder;
          childCompileElement.distanceToInheritedBinder = current.distanceToInheritedBinder + 1;
          this._process(results, current, childCompileElement);
        }
        node = nextNode;
      }
    }

    if (isPresent(additionalChildren)) {
      for (var i = 0; i < additionalChildren.length; i++) {
        this._process(results, current, additionalChildren[i]);
      }
    }
  }
开发者ID:AsherBarak,项目名称:angular,代码行数:27,代码来源:compile_pipeline.ts

示例4: it

 it('should move the style element to the style host', () => {
   var compileElement = el('<div><style>.one {}</style></div>');
   var styleElement = DOM.firstChild(compileElement);
   strategy.processStyleElement('someComponent', 'http://base', styleElement);
   expect(compileElement).toHaveText('');
   expect(styleHost).toHaveText('.one[_ngcontent-0] {\n\n}');
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:7,代码来源:emulated_scoped_shadow_dom_strategy_spec.ts

示例5: it

    it('should not coalesque text nodes', () => {
      var el1 = el('<div>a</div>');
      var el2 = el('<div>b</div>');
      DOM.appendChild(el2, DOM.firstChild(el1));
      expect(DOM.childNodes(el2).length).toBe(2);

      var el2Clone = DOM.clone(el2);
      expect(DOM.childNodes(el2Clone).length).toBe(2);
    });
开发者ID:goderbauer,项目名称:angular,代码行数:9,代码来源:dom_adapter_spec.ts

示例6: it

 it('should attach the view nodes as child of the host element', () => {
   var host = el('<div><span>original content</span></div>');
   var nodes = el('<div>view</div>');
   var pv = new ProtoView(nodes, new DynamicProtoChangeDetector(null, null), null);
   var view = pv.instantiate(null, null);
   strategy.attachTemplate(host, view);
   var firstChild = DOM.firstChild(host);
   expect(DOM.tagName(firstChild).toLowerCase()).toEqual('div');
   expect(firstChild).toHaveText('view');
   expect(host).toHaveText('view');
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:11,代码来源:shadow_dom_strategy_spec.ts

示例7: it

    it('by default events are only caught on same element', () => {
      var element = el('<div><div></div></div>');
      var child = DOM.firstChild(element);
      var dispatchedEvent = DOM.createMouseEvent('click');
      var receivedEvent = null;
      var handler = (e) => { receivedEvent = e; };
      var manager = new EventManager([domEventPlugin], new FakeNgZone());
      manager.addEventListener(element, 'click', handler);
      DOM.dispatchEvent(child, dispatchedEvent);

      expect(receivedEvent).toBe(null);
    });
开发者ID:188799958,项目名称:angular,代码行数:12,代码来源:event_manager_spec.ts

示例8: it

    it('should move the style element to the style host when @imports are present', inject([AsyncTestCompleter], (async) => {
      xhr.reply('http://base/one.css', '.one {}');

      var compileElement = el('<div><style>@import "one.css";</style></div>');
      var styleElement = DOM.firstChild(compileElement);
      var stylePromise = strategy.processStyleElement('someComponent', 'http://base', styleElement);

      stylePromise.then((_) => {
        expect(compileElement).toHaveText('');
        expect(styleHost).toHaveText('.one[_ngcontent-0] {\n\n}');
        async.done();
      });
    }));
开发者ID:NickWang1980,项目名称:angular,代码行数:13,代码来源:emulated_scoped_shadow_dom_strategy_spec.ts


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