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


TypeScript DOM.remove方法代码示例

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


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

示例1: processStyleElement

 processStyleElement(hostComponentId, templateUrl, styleEl) {
   var cssText = DOM.getText(styleEl);
   cssText = this.styleUrlResolver.resolveUrls(cssText, templateUrl);
   DOM.setText(styleEl, cssText);
   DOM.remove(styleEl);
   insertSharedStyleText(cssText, this.styleHost, styleEl);
   return null;
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:8,代码来源:emulated_unscoped_shadow_dom_strategy.ts

示例2: process

  process(parent: CompileElement, current: CompileElement, control: CompileControl) {
    var attrs = current.attrs();
    var templateBindings = attrs.get('template');
    var hasTemplateBinding = isPresent(templateBindings);

    // look for template shortcuts such as *ng-if="condition" and treat them as template="if
    // condition"
    MapWrapper.forEach(attrs, (attrValue, attrName) => {
      if (StringWrapper.startsWith(attrName, '*')) {
        var key = StringWrapper.substring(attrName, 1);  // remove the star
        if (hasTemplateBinding) {
          // 2nd template binding detected
          throw new BaseException(`Only one template directive per element is allowed: ` +
                                  `${templateBindings} and ${key} cannot be used simultaneously ` +
                                  `in ${current.elementDescription}`);
        } else {
          templateBindings = (attrValue.length == 0) ? key : key + ' ' + attrValue;
          hasTemplateBinding = true;
        }
      }
    });

    if (isPresent(parent)) {
      if (DOM.isTemplateElement(current.element)) {
        if (!current.isViewRoot) {
          var viewRoot = new CompileElement(DOM.createTemplate(''));
          viewRoot.inheritedProtoView = current.bindElement().bindNestedProtoView(viewRoot.element);
          // viewRoot doesn't appear in the original template, so we associate
          // the current element description to get a more meaningful message in case of error
          viewRoot.elementDescription = current.elementDescription;
          viewRoot.isViewRoot = true;

          this._moveChildNodes(DOM.content(current.element), DOM.content(viewRoot.element));
          control.addChild(viewRoot);
        }
      }
      if (hasTemplateBinding) {
        var newParent = new CompileElement(DOM.createTemplate(''));
        newParent.inheritedProtoView = current.inheritedProtoView;
        newParent.inheritedElementBinder = current.inheritedElementBinder;
        newParent.distanceToInheritedBinder = current.distanceToInheritedBinder;
        // newParent doesn't appear in the original template, so we associate
        // the current element description to get a more meaningful message in case of error
        newParent.elementDescription = current.elementDescription;

        current.inheritedProtoView = newParent.bindElement().bindNestedProtoView(current.element);
        current.inheritedElementBinder = null;
        current.distanceToInheritedBinder = 0;
        current.isViewRoot = true;
        this._parseTemplateBindings(templateBindings, newParent);

        this._addParentElement(current.element, newParent.element);
        control.addParent(newParent);
        DOM.remove(current.element);
      }
    }
  }
开发者ID:Salim-K,项目名称:angular,代码行数:57,代码来源:view_splitter.ts

示例3: _processContentElement

 _processContentElement(current) {
   if (this._shadowDomStrategy.hasNativeContentElement()) {
     return ;
   }
   var attrs = current.attrs();
   var selector = MapWrapper.get(attrs, 'select');
   selector = isPresent(selector) ? selector : '';
   var contentStart = DOM.createScriptTag('type', 'ng/contentStart');
   if (assertionsEnabled()) {
     DOM.setAttribute(contentStart, 'select', selector);
   }
   var contentEnd = DOM.createScriptTag('type', 'ng/contentEnd');
   DOM.insertBefore(current.element, contentStart);
   DOM.insertBefore(current.element, contentEnd);
   DOM.remove(current.element);
   current.element = contentStart;
   current.bindElement().setContentTagSelector(selector);
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:18,代码来源:shadow_dom_compile_step.ts

示例4: processStyleElement

 processStyleElement(hostComponentId, templateUrl, styleEl) {
   var cssText = DOM.getText(styleEl);
   cssText = this.styleUrlResolver.resolveUrls(cssText, templateUrl);
   var css = this.styleInliner.inlineImports(cssText, templateUrl);
   if (PromiseWrapper.isPromise(css)) {
     DOM.setText(styleEl, '');
     return css.then((css) => {
       css = shimCssForComponent(css, hostComponentId);
       DOM.setText(styleEl, css);
     });
   } else {
     css = shimCssForComponent(css, hostComponentId);
     DOM.setText(styleEl, css);
   }
   DOM.remove(styleEl);
   insertStyleElement(this.styleHost, styleEl);
   return null;
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:18,代码来源:emulated_scoped_shadow_dom_strategy.ts

示例5: process

 process(parent, current, control) {
   var attrs = current.attrs();
   var templateBindings = MapWrapper.get(attrs, 'template');
   var hasTemplateBinding = isPresent(templateBindings);
   MapWrapper.forEach(attrs, (attrValue, attrName) => {
     if (StringWrapper.startsWith(attrName, '*')) {
       var key = StringWrapper.substring(attrName, 1);
       if (hasTemplateBinding) {
         throw new BaseException(`Only one template directive per element is allowed: ` + `${templateBindings} and ${key} cannot be used simultaneously ` + `in ${current.elementDescription}`);
       } else {
         templateBindings = (attrValue.length == 0) ? key : key + ' ' + attrValue;
         hasTemplateBinding = true;
       }
     }
   });
   if (isPresent(parent)) {
     if (DOM.isTemplateElement(current.element)) {
       if (!current.isViewRoot) {
         var viewRoot = new CompileElement(DOM.createTemplate(''));
         viewRoot.inheritedProtoView = current.bindElement().bindNestedProtoView(viewRoot.element);
         viewRoot.elementDescription = current.elementDescription;
         viewRoot.isViewRoot = true;
         this._moveChildNodes(DOM.content(current.element), DOM.content(viewRoot.element));
         control.addChild(viewRoot);
       }
     }
     if (hasTemplateBinding) {
       var newParent = new CompileElement(DOM.createTemplate(''));
       newParent.inheritedProtoView = current.inheritedProtoView;
       newParent.inheritedElementBinder = current.inheritedElementBinder;
       newParent.distanceToInheritedBinder = current.distanceToInheritedBinder;
       newParent.elementDescription = current.elementDescription;
       current.inheritedProtoView = newParent.bindElement().bindNestedProtoView(current.element);
       current.inheritedElementBinder = null;
       current.distanceToInheritedBinder = 0;
       current.isViewRoot = true;
       this._parseTemplateBindings(templateBindings, newParent);
       this._addParentElement(current.element, newParent.element);
       control.addParent(newParent);
       DOM.remove(current.element);
     }
   }
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:43,代码来源:view_splitter.ts

示例6: processStyleElement

  processStyleElement(hostComponentId: string, templateUrl: string, styleEl): Promise<any> {
    var cssText = DOM.getText(styleEl);

    cssText = this.styleUrlResolver.resolveUrls(cssText, templateUrl);
    var inlinedCss = this.styleInliner.inlineImports(cssText, templateUrl);

    if (isPresent(inlinedCss.asyncResult)) {
      DOM.setText(styleEl, '');
      return inlinedCss.asyncResult.then((css) => {
        css = shimCssForComponent(css, hostComponentId);
        DOM.setText(styleEl, css);
      });
    } else {
      var css = shimCssForComponent(inlinedCss.syncResult, hostComponentId);
      DOM.setText(styleEl, css);
      DOM.remove(styleEl);
      insertStyleElement(this.styleHost, styleEl);
      return null;
    }
  }
开发者ID:baraksu,项目名称:angular,代码行数:20,代码来源:emulated_scoped_shadow_dom_strategy.ts

示例7: _processContentElement

  _processContentElement(current: CompileElement) {
    if (this._shadowDomStrategy.hasNativeContentElement()) {
      return;
    }
    var attrs = current.attrs();
    var selector = attrs.get('select');
    selector = isPresent(selector) ? selector : '';

    // The content tag should be replaced by a pair of marker tags (start & end).
    // The end marker creation is delayed to keep the number of elements constant.
    // Creating the end marker here would invalidate the parent's textNodeIndices for the subsequent
    // text nodes
    var contentStart = DOM.createScriptTag('type', 'ng/contentStart');
    if (assertionsEnabled()) {
      DOM.setAttribute(contentStart, 'select', selector);
    }
    DOM.insertBefore(current.element, contentStart);
    DOM.remove(current.element);

    current.element = contentStart;
    current.bindElement().setContentTagSelector(selector);
  }
开发者ID:adrianojdesouza,项目名称:angular,代码行数:22,代码来源:shadow_dom_compile_step.ts

示例8: redistributeNodes

// Projects the light DOM into the shadow DOM
function redistributeNodes(contents: List<Content>, nodes: List</*node*/ any>) {
  for (var i = 0; i < contents.length; ++i) {
    var content = contents[i];
    var select = content.select;

    // Empty selector is identical to <content/>
    if (select.length === 0) {
      content.insert(ListWrapper.clone(nodes));
      ListWrapper.clear(nodes);
    } else {
      var matchSelector = (n) => DOM.elementMatches(n, select);
      var matchingNodes = ListWrapper.filter(nodes, matchSelector);
      content.insert(matchingNodes);
      ListWrapper.removeAll(nodes, matchingNodes);
    }
  }
  for (var i = 0; i < nodes.length; i++) {
    var node = nodes[i];
    if (isPresent(node.parentNode)) {
      DOM.remove(nodes[i]);
    }
  }
}
开发者ID:B-Thapa,项目名称:angular,代码行数:24,代码来源:light_dom.ts

示例9: _moveToStyleHost

 _moveToStyleHost(styleEl): void {
   DOM.remove(styleEl);
   insertStyleElement(this.styleHost, styleEl);
 }
开发者ID:cedriclam,项目名称:angular,代码行数:4,代码来源:emulated_scoped_shadow_dom_strategy.ts


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