UNPKG

angular2

Version:

Angular 2 - a web framework for modern web apps

1 lines 6.03 kB
{"version":3,"sources":["emulated_scoped_shadow_dom_strategy.js"],"names":[],"mappings":"AAAA;AAAA,KAAK,iBAAiB,AAAC,CAAC,MAAK,QAAQ;iCAArC,EAAC,GAAE,YAAqB;AAAE,4CAAwB;IAAE,AAA9B,CAAC;AAAvB,WAAS,CAAT,EAAC,KAAI,CAAO,KAAG,AAAS,CAAC;CAAgC,CAAC;;;;;;;;SAA1D,EAAC,wCAAoB,CAAA,OAAM,AAAC,4BAAkB,CACtC,CAAA,yCAAqB,kDAA2B,CAAA,yCAAqB,GAAK,EAAC,OAAM,wCAAmB,CAAC,AAD/D,CACgE;AADtG,UAAM;AAAG,YAAQ;SAAzB,EAAC,yCAAoB,CAAA,OAAM,AAAC,6BAAkB,CACtC,CAAA,0CAAqB,mDAA2B,CAAA,0CAAqB,GAAK,EAAC,OAAM,yCAAmB,CAAC,AAD/D,CACgE;AAAtG,iBAAa;AAAG,UAAM;EAEtB,IAAE,EAHV,EAAC,+CAAoB,CAAA,OAAM,AAAC,gCAAkB,CACtC,CAAA,gDAAqB,yDAA2B,CAAA,gDAAqB,GAAK,EAAC,OAAM,+CAAmB,CAAC,AAD/D,CACgE;EAItG,aAAW,EALnB,EAAC,4EAAoB,CAAA,OAAM,AAAC,oDAAkB,CACtC,CAAA,6EAAqB,sFAA2B,CAAA,6EAAqB,GAAK,EAAC,OAAM,4EAAmB,CAAC,AAD/D,CACgE;EAKtG,iBAAe,EANvB,EAAC,oFAAoB,CAAA,OAAM,AAAC,yDAAkB,CACtC,CAAA,qFAAqB,8FAA2B,CAAA,qFAAqB,GAAK,EAAC,OAAM,oFAAmB,CAAC,AAD/D,CACgE;EAMtG,kCAAgC,EAPxC,EAAC,wDAAoB,CAAA,OAAM,AAAC,2CAAkB,CACtC,CAAA,yDAAqB,kEAA2B,CAAA,yDAAqB,GAAK,EAAC,OAAM,wDAAmB,CAAC,AAD/D,CACgE;SAD9G,EAA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AAAD,CAAG;AAAC,YAD1B,eAAc,KAAO,WAArB,eAAc,KAAO,cAC4B;EAAC,CAAC,CAAC,CAAC;AAkErD","file":"angular2/src/render/dom/shadow_dom/emulated_scoped_shadow_dom_strategy.js","sourcesContent":["import {isBlank, isPresent} from 'angular2/src/facade/lang';\nimport {PromiseWrapper, Promise} from 'angular2/src/facade/async';\n\nimport {DOM} from 'angular2/src/dom/dom_adapter';\n\nimport {StyleInliner} from 'angular2/src/render/dom/shadow_dom/style_inliner';\nimport {StyleUrlResolver} from 'angular2/src/render/dom/shadow_dom/style_url_resolver';\nimport {EmulatedUnscopedShadowDomStrategy} from './emulated_unscoped_shadow_dom_strategy';\nimport {\n getContentAttribute, getHostAttribute, getComponentId, shimCssForComponent, insertStyleElement\n} from './util';\n\n/**\n * This strategy emulates the Shadow DOM for the templates, styles **included**:\n * - components templates are added as children of their component element,\n * - both the template and the styles are modified so that styles are scoped to the component\n * they belong to,\n * - styles are moved from the templates to the styleHost (i.e. the document head).\n *\n * Notes:\n * - styles are scoped to their component and will apply only to it,\n * - a common subset of shadow DOM selectors are supported,\n * - see `ShadowCss` for more information and limitations.\n */\nexport class EmulatedScopedShadowDomStrategy extends EmulatedUnscopedShadowDomStrategy {\n styleInliner: StyleInliner;\n\n constructor(styleInliner: StyleInliner, styleUrlResolver: StyleUrlResolver, styleHost) {\n super(styleUrlResolver, styleHost);\n this.styleInliner = styleInliner;\n }\n\n processStyleElement(hostComponentId:string, templateUrl:string, styleEl):Promise {\n var cssText = DOM.getText(styleEl);\n\n cssText = this.styleUrlResolver.resolveUrls(cssText, templateUrl);\n var css = this.styleInliner.inlineImports(cssText, templateUrl);\n\n if (PromiseWrapper.isPromise(css)) {\n DOM.setText(styleEl, '');\n return css.then((css) => {\n css = shimCssForComponent(css, hostComponentId);\n DOM.setText(styleEl, css);\n });\n } else {\n css = shimCssForComponent(css, hostComponentId);\n DOM.setText(styleEl, css);\n }\n\n DOM.remove(styleEl);\n insertStyleElement(this.styleHost, styleEl);\n return null;\n }\n\n processElement(hostComponentId:string, elementComponentId:string, element) {\n // Shim the element as a child of the compiled component\n if (isPresent(hostComponentId)) {\n var contentAttribute = getContentAttribute(getComponentId(hostComponentId));\n DOM.setAttribute(element, contentAttribute, '');\n }\n // If the current element is also a component, shim it as a host\n if (isPresent(elementComponentId)) {\n var hostAttribute = getHostAttribute(getComponentId(elementComponentId));\n DOM.setAttribute(element, hostAttribute, '');\n }\n }\n}\n"]}