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


TypeScript DOM.setAttribute方法代码示例

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


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

示例1: processElement

 processElement(hostComponentId, elementComponentId, element) {
   if (isPresent(hostComponentId)) {
     var contentAttribute = getContentAttribute(getComponentId(hostComponentId));
     DOM.setAttribute(element, contentAttribute, '');
   }
   if (isPresent(elementComponentId)) {
     var hostAttribute = getHostAttribute(getComponentId(elementComponentId));
     DOM.setAttribute(element, hostAttribute, '');
   }
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:10,代码来源:emulated_scoped_shadow_dom_strategy.ts

示例2: processElement

 processElement(hostComponentId: string, elementComponentId: string, element): void {
   // Shim the element as a child of the compiled component
   if (isPresent(hostComponentId)) {
     var contentAttribute = getContentAttribute(getComponentId(hostComponentId));
     DOM.setAttribute(element, contentAttribute, '');
   }
   // If the current element is also a component, shim it as a host
   if (isPresent(elementComponentId)) {
     var hostAttribute = getHostAttribute(getComponentId(elementComponentId));
     DOM.setAttribute(element, hostAttribute, '');
   }
 }
开发者ID:cedriclam,项目名称:angular,代码行数:12,代码来源:emulated_scoped_shadow_dom_strategy.ts

示例3: _addHostAttribute

 _addHostAttribute(attrName, attrValue, compileElement) {
   if (StringWrapper.equals(attrName, 'class')) {
     ListWrapper.forEach(attrValue.split(' '),
                         (className) => { DOM.addClass(compileElement.element, className); });
   } else if (!DOM.hasAttribute(compileElement.element, attrName)) {
     DOM.setAttribute(compileElement.element, attrName, attrValue);
   }
 }
开发者ID:baraksu,项目名称:angular,代码行数:8,代码来源:directive_parser.ts

示例4: function

 setterFn = function(element, value) {
   if (_isValidAttributeValue(dashCasedAttributeName, value)) {
     DOM.setAttribute(element, dashCasedAttributeName, stringify(value));
   } else {
     if (isPresent(value)) {
       throw new BaseException("Invalid " + dashCasedAttributeName + " attribute, only string values are allowed, got '" + stringify(value) + "'");
     }
     DOM.removeAttribute(element, dashCasedAttributeName);
   }
 };
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:10,代码来源:property_setter_factory.ts

示例5: it

        it('should return a relative url', () => {
          var baseEl = DOM.createElement('base');
          DOM.setAttribute(baseEl, 'href', 'base');
          var headEl = DOM.defaultDoc().head;
          DOM.appendChild(headEl, baseEl);

          var baseHref = DOM.getBaseHref();
          DOM.removeChild(headEl, baseEl);
          DOM.resetBaseElement();

          expect(baseHref).toEqual('/base');
        });
开发者ID:lavinjj,项目名称:angular,代码行数:12,代码来源:dom_adapter_spec.ts

示例6: _processEmulatedScopedElement

 _processEmulatedScopedElement(current: CompileElement, parent: CompileElement): void {
   var element = current.element;
   var hostComponentId = this._view.componentId;
   var viewType = current.inheritedProtoView.type;
   // Shim the element as a child of the compiled component
   if (viewType !== ViewType.HOST && isPresent(hostComponentId)) {
     var contentAttribute = getContentAttribute(this._getComponentId(hostComponentId));
     DOM.setAttribute(element, contentAttribute, '');
     // also shim the host
     if (isBlank(parent) && viewType == ViewType.COMPONENT) {
       var hostAttribute = getHostAttribute(this._getComponentId(hostComponentId));
       current.inheritedProtoView.setHostAttribute(hostAttribute, '');
     }
   }
 }
开发者ID:KenWilliamson,项目名称:Angular2HostedMobileApp,代码行数:15,代码来源:style_encapsulator.ts

示例7: _parseTemplateBindings

 _parseTemplateBindings(templateBindings, compileElement) {
   var bindings = this._parser.parseTemplateBindings(templateBindings, compileElement.elementDescription);
   for (var i = 0; i < bindings.length; i++) {
     var binding = bindings[i];
     if (binding.keyIsVar) {
       compileElement.bindElement().bindVariable(dashCaseToCamelCase(binding.key), binding.name);
       MapWrapper.set(compileElement.attrs(), binding.key, binding.name);
     } else if (isPresent(binding.expression)) {
       compileElement.bindElement().bindProperty(dashCaseToCamelCase(binding.key), binding.expression);
       MapWrapper.set(compileElement.attrs(), binding.key, binding.expression.source);
     } else {
       DOM.setAttribute(compileElement.element, binding.key, '');
     }
   }
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:15,代码来源:view_splitter.ts

示例8: _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

示例9: it

    it('should clone correctly', () => {
      var el1 = el('<div x="y">a<span>b</span></div>');
      var clone = DOM.clone(el1);

      expect(clone).not.toBe(el1);
      DOM.setAttribute(clone, 'test', '1');
      expect(stringifyElement(clone)).toEqual('<div test="1" x="y">a<span>b</span></div>');
      expect(DOM.getAttribute(el1, 'test')).toBeFalsy();

      var cNodes = DOM.childNodes(clone);
      var firstChild = cNodes[0];
      var secondChild = cNodes[1];
      expect(DOM.parentElement(firstChild)).toBe(clone);
      expect(DOM.nextSibling(firstChild)).toBe(secondChild);
      expect(DOM.isTextNode(firstChild)).toBe(true);

      expect(DOM.parentElement(secondChild)).toBe(clone);
      expect(DOM.nextSibling(secondChild)).toBeFalsy();
      expect(DOM.isElementNode(secondChild)).toBe(true);

    });
开发者ID:goderbauer,项目名称:angular,代码行数:21,代码来源:dom_adapter_spec.ts


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