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


TypeScript DOM.childNodes方法代码示例

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


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

示例1: 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

示例2: compile

 compile('<input (change)="$event.target.value">', []).then((pvRefs) => {
   var viewRef = renderer.createView(pvRefs[0])[1];
   var dispatcher = new LoggingEventDispatcher();
   renderer.setEventDispatcher(viewRef, dispatcher);
   var inputEl = DOM.childNodes(rootEl)[0];
   inputEl.value = 'hello';
   eventPlugin.dispatchEvent('change', new FakeEvent(inputEl));
   expect(dispatcher.log).toEqual([[0, 'change', ['hello']]]);
   async.done();
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:10,代码来源:direct_dom_renderer_integration_spec.ts

示例3: queryBoundTextNodeIndices

export function queryBoundTextNodeIndices(parentNode: Node, boundTextNodes: Map<Node, any>,
                                          resultCallback: Function) {
  var childNodes = DOM.childNodes(parentNode);
  for (var j = 0; j < childNodes.length; j++) {
    var node = childNodes[j];
    if (boundTextNodes.has(node)) {
      resultCallback(node, j, boundTextNodes.get(node));
    }
  }
}
开发者ID:goderbauer,项目名称:angular,代码行数:10,代码来源:util.ts

示例4: createView

 function createView(pv = null, boundElementCount = 0) {
   if (isBlank(pv)) {
     pv = createProtoView();
   }
   var root = el('<div><div></div></div>');
   var boundElements = [];
   for (var i = 0; i < boundElementCount; i++) {
     boundElements.push(new DomElement(pv.elementBinders[i], el('<span></span'), null));
   }
   return new DomView(pv, [DOM.childNodes(root)[0]], [], boundElements);
 }
开发者ID:AsherBarak,项目名称:angular,代码行数:11,代码来源:view_spec.ts

示例5: queryBoundTextNodes

function queryBoundTextNodes(templateContent: Node, rootTextNodeIndices: number[],
                             boundElements: Element[], elementBinders: DomElementBinder[],
                             boundTextNodeCount: number): Node[] {
  var boundTextNodes = ListWrapper.createFixedSize(boundTextNodeCount);
  var textNodeIndex = 0;
  if (rootTextNodeIndices.length > 0) {
    var rootChildNodes = DOM.childNodes(templateContent);
    for (var i = 0; i < rootTextNodeIndices.length; i++) {
      boundTextNodes[textNodeIndex++] = rootChildNodes[rootTextNodeIndices[i]];
    }
  }
  for (var i = 0; i < elementBinders.length; i++) {
    var binder = elementBinders[i];
    var element: Node = boundElements[i];
    if (binder.textNodeIndices.length > 0) {
      var childNodes = DOM.childNodes(element);
      for (var j = 0; j < binder.textNodeIndices.length; j++) {
        boundTextNodes[textNodeIndex++] = childNodes[binder.textNodeIndices[j]];
      }
    }
  }
  return boundTextNodes;
}
开发者ID:goderbauer,项目名称:angular,代码行数:23,代码来源:util.ts

示例6: process

 process(parent: CompileElement, current: CompileElement, control: CompileControl) {
   if (!current.compileChildren) {
     return;
   }
   var element = current.element;
   var childNodes = DOM.childNodes(DOM.templateAwareRoot(element));
   for (var i = 0; i < childNodes.length; i++) {
     var node = childNodes[i];
     if (DOM.isTextNode(node)) {
       var text = DOM.nodeValue(node);
       var expr = this._parser.parseInterpolation(text, current.elementDescription);
       if (isPresent(expr)) {
         DOM.setText(node, ' ');
         current.bindElement().bindText(node, expr);
       }
     }
   }
 }
开发者ID:Salim-K,项目名称:angular,代码行数:18,代码来源:text_interpolation_parser.ts

示例7: stringifyElement

export function stringifyElement(el): string {
  var result = '';
  if (DOM.isElementNode(el)) {
    var tagName = StringWrapper.toLowerCase(DOM.tagName(el));

    // Opening tag
    result += `<${tagName}`;

    // Attributes in an ordered way
    var attributeMap = DOM.attributeMap(el);
    var keys = [];
    MapWrapper.forEach(attributeMap, (v, k) => { keys.push(k); });
    ListWrapper.sort(keys);
    for (let i = 0; i < keys.length; i++) {
      var key = keys[i];
      var attValue = MapWrapper.get(attributeMap, key);
      if (!isString(attValue)) {
        result += ` ${key}`;
      } else {
        result += ` ${key}="${attValue}"`;
      }
    }
    result += '>';

    // Children
    var children = DOM.childNodes(DOM.templateAwareRoot(el));
    for (let j = 0; j < children.length; j++) {
      result += stringifyElement(children[j]);
    }

    // Closing tag
    if (!ListWrapper.contains(_singleTagWhitelist, tagName)) {
      result += `</${tagName}>`;
    }
  } else {
    result += DOM.getText(el);
  }

  return result;
}
开发者ID:AsherBarak,项目名称:angular,代码行数:40,代码来源:utils.ts

示例8: assertElementTextBinding

 function assertElementTextBinding(elementBinderBuilder: ElementBinderBuilder, nodeIndex: number,
                                   expression: string) {
   var node = DOM.childNodes(DOM.templateAwareRoot(elementBinderBuilder.element))[nodeIndex];
   expect(elementBinderBuilder.textBindings.get(node).source).toEqual(expression);
 }
开发者ID:goderbauer,项目名称:angular,代码行数:5,代码来源:text_interpolation_parser_spec.ts


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