2016-04-28 20:50:03 -04:00
|
|
|
import {
|
|
|
|
Inject,
|
|
|
|
Injectable,
|
|
|
|
OpaqueToken,
|
|
|
|
Renderer,
|
|
|
|
RootRenderer,
|
|
|
|
RenderComponentType,
|
|
|
|
ViewEncapsulation
|
|
|
|
} from '@angular/core';
|
2016-04-12 12:40:37 -04:00
|
|
|
import {
|
|
|
|
isPresent,
|
|
|
|
isBlank,
|
|
|
|
Json,
|
|
|
|
RegExpWrapper,
|
|
|
|
stringify,
|
|
|
|
StringWrapper,
|
2016-04-13 20:05:17 -04:00
|
|
|
isArray,
|
|
|
|
isString
|
2016-05-31 18:22:59 -04:00
|
|
|
} from '../facade/lang';
|
2015-05-06 13:49:42 -04:00
|
|
|
|
2016-05-31 18:22:59 -04:00
|
|
|
import {StringMapWrapper} from '../facade/collection';
|
2016-04-29 18:18:53 -04:00
|
|
|
|
2016-05-31 18:22:59 -04:00
|
|
|
import {BaseException} from '../facade/exceptions';
|
2015-10-02 12:30:36 -04:00
|
|
|
import {DomSharedStylesHost} from './shared_styles_host';
|
2016-05-25 15:46:22 -04:00
|
|
|
|
|
|
|
import {
|
|
|
|
AnimationKeyframe,
|
|
|
|
AnimationStyles,
|
|
|
|
AnimationPlayer,
|
2016-05-26 18:07:51 -04:00
|
|
|
AnimationDriver,
|
|
|
|
RenderDebugInfo,
|
2016-05-25 15:46:22 -04:00
|
|
|
} from '../../core_private';
|
|
|
|
|
2015-11-24 18:05:04 -05:00
|
|
|
import {EventManager} from './events/event_manager';
|
2015-08-20 18:11:12 -04:00
|
|
|
import {DOCUMENT} from './dom_tokens';
|
2016-04-28 20:50:03 -04:00
|
|
|
import {getDOM} from './dom_adapter';
|
2015-12-10 13:11:39 -05:00
|
|
|
import {camelCaseToDashCase} from './util';
|
2015-11-17 18:24:36 -05:00
|
|
|
|
2016-02-11 16:39:02 -05:00
|
|
|
const NAMESPACE_URIS =
|
2016-04-26 00:47:33 -04:00
|
|
|
{'xlink': 'http://www.w3.org/1999/xlink', 'svg': 'http://www.w3.org/2000/svg'};
|
2015-11-19 14:14:44 -05:00
|
|
|
const TEMPLATE_COMMENT_TEXT = 'template bindings={}';
|
|
|
|
var TEMPLATE_BINDINGS_EXP = /^template bindings=(.*)$/g;
|
2015-10-27 16:16:27 -04:00
|
|
|
|
2015-12-02 13:35:51 -05:00
|
|
|
export abstract class DomRootRenderer implements RootRenderer {
|
2016-02-01 18:51:00 -05:00
|
|
|
protected registeredComponents: Map<string, DomRenderer> = new Map<string, DomRenderer>();
|
2015-10-06 09:53:39 -04:00
|
|
|
|
2016-04-12 12:40:37 -04:00
|
|
|
constructor(public document: any, public eventManager: EventManager,
|
2016-05-25 15:46:22 -04:00
|
|
|
public sharedStylesHost: DomSharedStylesHost,
|
|
|
|
public animationDriver: AnimationDriver) {}
|
2015-10-06 09:53:39 -04:00
|
|
|
|
2015-12-02 13:35:51 -05:00
|
|
|
renderComponent(componentProto: RenderComponentType): Renderer {
|
2016-02-01 18:51:00 -05:00
|
|
|
var renderer = this.registeredComponents.get(componentProto.id);
|
2015-12-02 13:35:51 -05:00
|
|
|
if (isBlank(renderer)) {
|
2016-05-25 15:46:22 -04:00
|
|
|
renderer = new DomRenderer(this, componentProto, this.animationDriver);
|
2016-02-01 18:51:00 -05:00
|
|
|
this.registeredComponents.set(componentProto.id, renderer);
|
2015-10-06 09:53:39 -04:00
|
|
|
}
|
2015-12-02 13:35:51 -05:00
|
|
|
return renderer;
|
2015-10-06 09:53:39 -04:00
|
|
|
}
|
2015-12-02 13:35:51 -05:00
|
|
|
}
|
2015-10-06 09:53:39 -04:00
|
|
|
|
2015-12-02 13:35:51 -05:00
|
|
|
@Injectable()
|
|
|
|
export class DomRootRenderer_ extends DomRootRenderer {
|
2016-04-12 12:40:37 -04:00
|
|
|
constructor(@Inject(DOCUMENT) _document: any, _eventManager: EventManager,
|
2016-05-25 15:46:22 -04:00
|
|
|
sharedStylesHost: DomSharedStylesHost,
|
|
|
|
animationDriver: AnimationDriver) {
|
|
|
|
super(_document, _eventManager, sharedStylesHost, animationDriver);
|
2015-10-06 09:53:39 -04:00
|
|
|
}
|
2015-12-02 13:35:51 -05:00
|
|
|
}
|
2015-10-06 09:53:39 -04:00
|
|
|
|
2015-12-02 13:35:51 -05:00
|
|
|
export class DomRenderer implements Renderer {
|
|
|
|
private _contentAttr: string;
|
|
|
|
private _hostAttr: string;
|
|
|
|
private _styles: string[];
|
2015-10-06 09:53:39 -04:00
|
|
|
|
2016-05-25 15:46:22 -04:00
|
|
|
constructor(private _rootRenderer: DomRootRenderer, private componentProto: RenderComponentType,
|
|
|
|
private _animationDriver: AnimationDriver) {
|
2015-12-02 13:35:51 -05:00
|
|
|
this._styles = _flattenStyles(componentProto.id, componentProto.styles, []);
|
|
|
|
if (componentProto.encapsulation !== ViewEncapsulation.Native) {
|
|
|
|
this._rootRenderer.sharedStylesHost.addStyles(this._styles);
|
|
|
|
}
|
|
|
|
if (this.componentProto.encapsulation === ViewEncapsulation.Emulated) {
|
|
|
|
this._contentAttr = _shimContentAttribute(componentProto.id);
|
|
|
|
this._hostAttr = _shimHostAttribute(componentProto.id);
|
|
|
|
} else {
|
|
|
|
this._contentAttr = null;
|
|
|
|
this._hostAttr = null;
|
|
|
|
}
|
2015-10-06 09:53:39 -04:00
|
|
|
}
|
|
|
|
|
2016-04-13 20:05:17 -04:00
|
|
|
selectRootElement(selectorOrNode: string | any, debugInfo: RenderDebugInfo): Element {
|
2016-06-08 18:45:15 -04:00
|
|
|
var el: any /** TODO #9100 */;
|
2016-04-13 20:05:17 -04:00
|
|
|
if (isString(selectorOrNode)) {
|
2016-04-28 20:50:03 -04:00
|
|
|
el = getDOM().querySelector(this._rootRenderer.document, selectorOrNode);
|
2016-04-13 20:05:17 -04:00
|
|
|
if (isBlank(el)) {
|
|
|
|
throw new BaseException(`The selector "${selectorOrNode}" did not match any elements`);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
el = selectorOrNode;
|
2015-10-06 09:53:39 -04:00
|
|
|
}
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().clearNodes(el);
|
2015-12-02 13:35:51 -05:00
|
|
|
return el;
|
2015-10-06 09:53:39 -04:00
|
|
|
}
|
|
|
|
|
2016-01-06 17:13:44 -05:00
|
|
|
createElement(parent: Element, name: string, debugInfo: RenderDebugInfo): Node {
|
2015-12-02 13:35:51 -05:00
|
|
|
var nsAndName = splitNamespace(name);
|
|
|
|
var el = isPresent(nsAndName[0]) ?
|
2016-06-08 18:45:15 -04:00
|
|
|
getDOM().createElementNS((NAMESPACE_URIS as any /** TODO #9100 */)[nsAndName[0]], nsAndName[1]) :
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().createElement(nsAndName[1]);
|
2015-12-02 13:35:51 -05:00
|
|
|
if (isPresent(this._contentAttr)) {
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().setAttribute(el, this._contentAttr, '');
|
2015-12-02 13:35:51 -05:00
|
|
|
}
|
|
|
|
if (isPresent(parent)) {
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().appendChild(parent, el);
|
2015-11-19 14:14:44 -05:00
|
|
|
}
|
2015-12-02 13:35:51 -05:00
|
|
|
return el;
|
2015-11-19 14:14:44 -05:00
|
|
|
}
|
|
|
|
|
2015-12-02 13:35:51 -05:00
|
|
|
createViewRoot(hostElement: any): any {
|
2016-06-08 18:45:15 -04:00
|
|
|
var nodesParent: any /** TODO #9100 */;
|
2015-12-02 13:35:51 -05:00
|
|
|
if (this.componentProto.encapsulation === ViewEncapsulation.Native) {
|
2016-04-28 20:50:03 -04:00
|
|
|
nodesParent = getDOM().createShadowRoot(hostElement);
|
2015-12-02 13:35:51 -05:00
|
|
|
this._rootRenderer.sharedStylesHost.addHost(nodesParent);
|
|
|
|
for (var i = 0; i < this._styles.length; i++) {
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().appendChild(nodesParent, getDOM().createStyleElement(this._styles[i]));
|
2015-12-02 13:35:51 -05:00
|
|
|
}
|
2015-10-06 09:53:39 -04:00
|
|
|
} else {
|
2015-12-02 13:35:51 -05:00
|
|
|
if (isPresent(this._hostAttr)) {
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().setAttribute(hostElement, this._hostAttr, '');
|
2015-12-02 13:35:51 -05:00
|
|
|
}
|
|
|
|
nodesParent = hostElement;
|
2015-10-06 09:53:39 -04:00
|
|
|
}
|
2015-12-02 13:35:51 -05:00
|
|
|
return nodesParent;
|
2015-10-06 09:53:39 -04:00
|
|
|
}
|
|
|
|
|
2016-01-06 17:13:44 -05:00
|
|
|
createTemplateAnchor(parentElement: any, debugInfo: RenderDebugInfo): any {
|
2016-04-28 20:50:03 -04:00
|
|
|
var comment = getDOM().createComment(TEMPLATE_COMMENT_TEXT);
|
2015-12-02 13:35:51 -05:00
|
|
|
if (isPresent(parentElement)) {
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().appendChild(parentElement, comment);
|
2015-10-06 09:53:39 -04:00
|
|
|
}
|
2015-12-02 13:35:51 -05:00
|
|
|
return comment;
|
2015-10-06 09:53:39 -04:00
|
|
|
}
|
|
|
|
|
2016-01-06 17:13:44 -05:00
|
|
|
createText(parentElement: any, value: string, debugInfo: RenderDebugInfo): any {
|
2016-04-28 20:50:03 -04:00
|
|
|
var node = getDOM().createTextNode(value);
|
2015-12-02 13:35:51 -05:00
|
|
|
if (isPresent(parentElement)) {
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().appendChild(parentElement, node);
|
2015-12-02 13:35:51 -05:00
|
|
|
}
|
|
|
|
return node;
|
2015-10-06 09:53:39 -04:00
|
|
|
}
|
|
|
|
|
2015-12-02 13:35:51 -05:00
|
|
|
projectNodes(parentElement: any, nodes: any[]) {
|
|
|
|
if (isBlank(parentElement)) return;
|
|
|
|
appendNodes(parentElement, nodes);
|
2015-10-06 09:53:39 -04:00
|
|
|
}
|
|
|
|
|
2015-12-02 13:35:51 -05:00
|
|
|
attachViewAfter(node: any, viewRootNodes: any[]) {
|
|
|
|
moveNodesAfterSibling(node, viewRootNodes);
|
2015-10-06 09:53:39 -04:00
|
|
|
}
|
|
|
|
|
2015-12-02 13:35:51 -05:00
|
|
|
detachView(viewRootNodes: any[]) {
|
|
|
|
for (var i = 0; i < viewRootNodes.length; i++) {
|
2016-05-25 15:46:22 -04:00
|
|
|
getDOM().remove(viewRootNodes[i]);
|
2015-12-02 13:35:51 -05:00
|
|
|
}
|
2015-05-06 13:49:42 -04:00
|
|
|
}
|
|
|
|
|
2015-12-02 13:35:51 -05:00
|
|
|
destroyView(hostElement: any, viewAllNodes: any[]) {
|
|
|
|
if (this.componentProto.encapsulation === ViewEncapsulation.Native && isPresent(hostElement)) {
|
2016-04-28 20:50:03 -04:00
|
|
|
this._rootRenderer.sharedStylesHost.removeHost(getDOM().getShadowRoot(hostElement));
|
2015-10-05 12:43:00 -04:00
|
|
|
}
|
2015-10-01 13:07:49 -04:00
|
|
|
}
|
|
|
|
|
2016-01-25 17:47:25 -05:00
|
|
|
listen(renderElement: any, name: string, callback: Function): Function {
|
2016-04-12 12:40:37 -04:00
|
|
|
return this._rootRenderer.eventManager.addEventListener(renderElement, name,
|
|
|
|
decoratePreventDefault(callback));
|
2015-12-02 13:35:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
listenGlobal(target: string, name: string, callback: Function): Function {
|
2016-04-12 12:40:37 -04:00
|
|
|
return this._rootRenderer.eventManager.addGlobalEventListener(target, name,
|
|
|
|
decoratePreventDefault(callback));
|
2015-11-02 11:39:14 -05:00
|
|
|
}
|
|
|
|
|
2015-12-02 13:35:51 -05:00
|
|
|
setElementProperty(renderElement: any, propertyName: string, propertyValue: any): void {
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().setProperty(renderElement, propertyName, propertyValue);
|
2015-10-01 13:07:49 -04:00
|
|
|
}
|
|
|
|
|
2015-12-02 13:35:51 -05:00
|
|
|
setElementAttribute(renderElement: any, attributeName: string, attributeValue: string): void {
|
2016-06-08 18:45:15 -04:00
|
|
|
var attrNs: any /** TODO #9100 */;
|
2015-12-02 13:35:51 -05:00
|
|
|
var nsAndName = splitNamespace(attributeName);
|
|
|
|
if (isPresent(nsAndName[0])) {
|
2016-02-11 16:44:16 -05:00
|
|
|
attributeName = nsAndName[0] + ':' + nsAndName[1];
|
2016-06-08 18:45:15 -04:00
|
|
|
attrNs = (NAMESPACE_URIS as any /** TODO #9100 */)[nsAndName[0]];
|
2015-12-02 13:35:51 -05:00
|
|
|
}
|
|
|
|
if (isPresent(attributeValue)) {
|
|
|
|
if (isPresent(attrNs)) {
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().setAttributeNS(renderElement, attrNs, attributeName, attributeValue);
|
2015-12-02 13:35:51 -05:00
|
|
|
} else {
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().setAttribute(renderElement, attributeName, attributeValue);
|
2015-12-02 13:35:51 -05:00
|
|
|
}
|
|
|
|
} else {
|
2016-01-08 15:01:29 -05:00
|
|
|
if (isPresent(attrNs)) {
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().removeAttributeNS(renderElement, attrNs, nsAndName[1]);
|
2016-01-08 15:01:29 -05:00
|
|
|
} else {
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().removeAttribute(renderElement, attributeName);
|
2016-01-08 15:01:29 -05:00
|
|
|
}
|
2015-05-06 13:49:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-02 13:35:51 -05:00
|
|
|
setBindingDebugInfo(renderElement: any, propertyName: string, propertyValue: string): void {
|
|
|
|
var dashCasedPropertyName = camelCaseToDashCase(propertyName);
|
2016-04-28 20:50:03 -04:00
|
|
|
if (getDOM().isCommentNode(renderElement)) {
|
2015-12-02 13:35:51 -05:00
|
|
|
var existingBindings = RegExpWrapper.firstMatch(
|
2016-05-02 01:50:37 -04:00
|
|
|
TEMPLATE_BINDINGS_EXP,
|
|
|
|
StringWrapper.replaceAll(getDOM().getText(renderElement), /\n/g, ''));
|
2015-12-02 13:35:51 -05:00
|
|
|
var parsedBindings = Json.parse(existingBindings[1]);
|
2016-06-08 18:45:15 -04:00
|
|
|
(parsedBindings as any /** TODO #9100 */)[dashCasedPropertyName] = propertyValue;
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().setText(renderElement, StringWrapper.replace(TEMPLATE_COMMENT_TEXT, '{}',
|
2016-05-02 01:50:37 -04:00
|
|
|
Json.stringify(parsedBindings)));
|
2015-12-02 13:35:51 -05:00
|
|
|
} else {
|
|
|
|
this.setElementAttribute(renderElement, propertyName, propertyValue);
|
|
|
|
}
|
2015-10-01 13:07:49 -04:00
|
|
|
}
|
|
|
|
|
2015-12-02 13:35:51 -05:00
|
|
|
setElementClass(renderElement: any, className: string, isAdd: boolean): void {
|
|
|
|
if (isAdd) {
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().addClass(renderElement, className);
|
2015-12-02 13:35:51 -05:00
|
|
|
} else {
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().removeClass(renderElement, className);
|
2015-10-01 13:07:49 -04:00
|
|
|
}
|
2015-05-06 13:49:42 -04:00
|
|
|
}
|
|
|
|
|
2015-12-02 13:35:51 -05:00
|
|
|
setElementStyle(renderElement: any, styleName: string, styleValue: string): void {
|
|
|
|
if (isPresent(styleValue)) {
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().setStyle(renderElement, styleName, stringify(styleValue));
|
2015-12-02 13:35:51 -05:00
|
|
|
} else {
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().removeStyle(renderElement, styleName);
|
2015-07-24 18:28:44 -04:00
|
|
|
}
|
2015-05-06 13:49:42 -04:00
|
|
|
}
|
|
|
|
|
2015-12-02 13:35:51 -05:00
|
|
|
invokeElementMethod(renderElement: any, methodName: string, args: any[]): void {
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().invoke(renderElement, methodName, args);
|
2015-12-02 13:35:51 -05:00
|
|
|
}
|
|
|
|
|
2016-04-28 20:50:03 -04:00
|
|
|
setText(renderNode: any, text: string): void { getDOM().setText(renderNode, text); }
|
2015-12-02 13:35:51 -05:00
|
|
|
|
2016-05-25 15:46:22 -04:00
|
|
|
animate(element: any,
|
|
|
|
startingStyles: AnimationStyles,
|
|
|
|
keyframes: AnimationKeyframe[], duration: number, delay: number,
|
|
|
|
easing: string): AnimationPlayer {
|
|
|
|
return this._animationDriver.animate(element, startingStyles, keyframes, duration, delay, easing);
|
2015-05-06 13:49:42 -04:00
|
|
|
}
|
2015-06-24 16:46:39 -04:00
|
|
|
}
|
2015-05-06 13:49:42 -04:00
|
|
|
|
2016-06-08 18:45:15 -04:00
|
|
|
function moveNodesAfterSibling(sibling: any /** TODO #9100 */, nodes: any /** TODO #9100 */) {
|
2016-04-28 20:50:03 -04:00
|
|
|
var parent = getDOM().parentElement(sibling);
|
2015-12-09 17:44:18 -05:00
|
|
|
if (nodes.length > 0 && isPresent(parent)) {
|
2016-04-28 20:50:03 -04:00
|
|
|
var nextSibling = getDOM().nextSibling(sibling);
|
2015-12-09 17:44:18 -05:00
|
|
|
if (isPresent(nextSibling)) {
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().insertBefore(nextSibling, nodes[i]);
|
2015-12-09 17:44:18 -05:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().appendChild(parent, nodes[i]);
|
2015-12-09 17:44:18 -05:00
|
|
|
}
|
2015-05-06 13:49:42 -04:00
|
|
|
}
|
2015-06-02 13:15:16 -04:00
|
|
|
}
|
2015-06-24 16:46:39 -04:00
|
|
|
}
|
2015-06-02 13:15:16 -04:00
|
|
|
|
2016-06-08 18:45:15 -04:00
|
|
|
function appendNodes(parent: any /** TODO #9100 */, nodes: any /** TODO #9100 */) {
|
2015-12-02 13:35:51 -05:00
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().appendChild(parent, nodes[i]);
|
2015-12-02 13:35:51 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-01 13:07:49 -04:00
|
|
|
function decoratePreventDefault(eventHandler: Function): Function {
|
2016-06-08 18:45:15 -04:00
|
|
|
return (event: any /** TODO #9100 */) => {
|
2015-10-01 13:07:49 -04:00
|
|
|
var allowDefaultBehavior = eventHandler(event);
|
2015-12-02 13:35:51 -05:00
|
|
|
if (allowDefaultBehavior === false) {
|
2015-10-01 13:07:49 -04:00
|
|
|
// TODO(tbosch): move preventDefault into event plugins...
|
2016-04-28 20:50:03 -04:00
|
|
|
getDOM().preventDefault(event);
|
2015-10-01 13:07:49 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2015-11-10 18:56:25 -05:00
|
|
|
|
2015-12-02 13:35:51 -05:00
|
|
|
var COMPONENT_REGEX = /%COMP%/g;
|
|
|
|
export const COMPONENT_VARIABLE = '%COMP%';
|
2016-05-20 19:11:49 -04:00
|
|
|
export const HOST_ATTR = `_nghost-${COMPONENT_VARIABLE}`;
|
|
|
|
export const CONTENT_ATTR = `_ngcontent-${COMPONENT_VARIABLE}`;
|
2015-12-02 13:35:51 -05:00
|
|
|
|
|
|
|
function _shimContentAttribute(componentShortId: string): string {
|
|
|
|
return StringWrapper.replaceAll(CONTENT_ATTR, COMPONENT_REGEX, componentShortId);
|
|
|
|
}
|
|
|
|
|
|
|
|
function _shimHostAttribute(componentShortId: string): string {
|
|
|
|
return StringWrapper.replaceAll(HOST_ATTR, COMPONENT_REGEX, componentShortId);
|
|
|
|
}
|
|
|
|
|
2016-04-12 12:40:37 -04:00
|
|
|
function _flattenStyles(compId: string, styles: Array<any | any[]>, target: string[]): string[] {
|
2015-12-02 13:35:51 -05:00
|
|
|
for (var i = 0; i < styles.length; i++) {
|
|
|
|
var style = styles[i];
|
|
|
|
if (isArray(style)) {
|
|
|
|
_flattenStyles(compId, style, target);
|
|
|
|
} else {
|
|
|
|
style = StringWrapper.replaceAll(style, COMPONENT_REGEX, compId);
|
|
|
|
target.push(style);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
|
2016-04-29 17:54:46 -04:00
|
|
|
var NS_PREFIX_RE = /^:([^:]+):(.+)/g;
|
2015-11-10 18:56:25 -05:00
|
|
|
|
|
|
|
function splitNamespace(name: string): string[] {
|
2016-04-29 17:54:46 -04:00
|
|
|
if (name[0] != ':') {
|
2015-11-10 18:56:25 -05:00
|
|
|
return [null, name];
|
|
|
|
}
|
|
|
|
let match = RegExpWrapper.firstMatch(NS_PREFIX_RE, name);
|
|
|
|
return [match[1], match[2]];
|
2016-01-08 15:01:29 -05:00
|
|
|
}
|