From c151f9cdc8a38ec1a5083b2e4f9e7e6318ef8227 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Wed, 6 Jun 2018 13:38:17 -0700 Subject: [PATCH] Revert "refactor(ivy): rename setNS, setHtmlNS and friends to namespace, namespaceHTML, etc (#23899)" This reverts commit 0d06c866c69bb9dec51c570afc2bd77977aacd23. --- packages/core/src/render3/instructions.ts | 40 ++++++------------- .../bundling/todo/bundle.golden_symbols.json | 2 +- .../core/test/render3/instructions_spec.ts | 6 +-- 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/packages/core/src/render3/instructions.ts b/packages/core/src/render3/instructions.ts index e195770c05..f6fad80f48 100644 --- a/packages/core/src/render3/instructions.ts +++ b/packages/core/src/render3/instructions.ts @@ -556,38 +556,22 @@ function getRenderFlags(view: LView): RenderFlags { ////////////////////////// //// Namespace ////////////////////////// -let _currentNamespace: string|null = null; +let _currentNS: string|null = null; -/** - * Sets the namespace URI that will be used to create elements in {@link element} - * and {@link elementStart} - * @param uri the full namespaceUri - */ -export function namespace(uri: string | null) { - _currentNamespace = uri; +export function setNS(namespace: string) { + _currentNS = namespace; } -/** - * Sets the current namespace URI to null, meaning createElement (not createElementNS) - * will be used to create elements in {@link element} and {@link elementStart} - */ -export function namespaceHTML() { - _currentNamespace = null; +export function setHtmlNS() { + _currentNS = null; } -/** - * Sets the current namespace URI to http://www.w3.org/2000/svg, which will be - * used in conjunction with createElementNS in {@link element} and {@link elementStart} - */ -export function namespaceSVG() { - _currentNamespace = 'http://www.w3.org/2000/svg'; +export function setSvgNS() { + _currentNS = 'http://www.w3.org/2000/svg'; } -/** - * Sets the current namespace URI to http://www.w3.org/1998/Math/MathML, which will be - * used in conjunction with createElementNS in {@link element} and {@link elementStart} - */ -export function namespaceMathML() { - _currentNamespace = 'http://www.w3.org/1998/Math/MathML'; + +export function setMathML() { + _currentNS = 'http://www.w3.org/1998/Math/MathML'; } @@ -615,9 +599,9 @@ export function elementStart( ngDevMode && ngDevMode.rendererCreateElement++; - const native: RElement = _currentNamespace === null || isProceduralRenderer(renderer) ? + const native: RElement = _currentNS === null || isProceduralRenderer(renderer) ? renderer.createElement(name) : - (renderer as ObjectOrientedRenderer3).createElementNS(_currentNamespace, name); + (renderer as ObjectOrientedRenderer3).createElementNS(_currentNS, name); ngDevMode && assertDataInRange(index - 1); diff --git a/packages/core/test/bundling/todo/bundle.golden_symbols.json b/packages/core/test/bundling/todo/bundle.golden_symbols.json index 8a2c2c97c0..2b63963bd6 100644 --- a/packages/core/test/bundling/todo/bundle.golden_symbols.json +++ b/packages/core/test/bundling/todo/bundle.golden_symbols.json @@ -177,7 +177,7 @@ "name": "_currentInjector" }, { - "name": "_currentNamespace" + "name": "_currentNS" }, { "name": "_devMode" diff --git a/packages/core/test/render3/instructions_spec.ts b/packages/core/test/render3/instructions_spec.ts index 32aa8fe6fc..b7e79be99d 100644 --- a/packages/core/test/render3/instructions_spec.ts +++ b/packages/core/test/render3/instructions_spec.ts @@ -10,7 +10,7 @@ import {NgForOfContext} from '@angular/common'; import {RenderFlags, directiveInject} from '../../src/render3'; import {defineComponent} from '../../src/render3/definition'; -import {bind, container, element, elementAttribute, elementClass, elementEnd, elementProperty, elementStart, elementStyle, elementStyleNamed, interpolation1, namespaceHTML, namespaceSVG, renderTemplate, text, textBinding} from '../../src/render3/instructions'; +import {bind, container, element, elementAttribute, elementClass, elementEnd, elementProperty, elementStart, elementStyle, elementStyleNamed, interpolation1, renderTemplate, setHtmlNS, setSvgNS, text, textBinding} from '../../src/render3/instructions'; import {AttributeMarker, LElementNode, LNode} from '../../src/render3/interfaces/node'; import {RElement, domRendererFactory3} from '../../src/render3/interfaces/renderer'; import {TrustedString, bypassSanitizationTrustHtml, bypassSanitizationTrustResourceUrl, bypassSanitizationTrustScript, bypassSanitizationTrustStyle, bypassSanitizationTrustUrl, sanitizeHtml, sanitizeResourceUrl, sanitizeScript, sanitizeStyle, sanitizeUrl} from '../../src/sanitization/sanitization'; @@ -433,7 +433,7 @@ describe('instructions', () => { it('should render SVG', () => { const t = new TemplateFixture(() => { elementStart(0, 'div', ['id', 'container']); - namespaceSVG(); + setSvgNS(); elementStart(1, 'svg', [ // id="display" 'id', @@ -452,7 +452,7 @@ describe('instructions', () => { ]); element(2, 'circle', ['cx', '200', 'cy', '150', 'fill', '#0000ff']); elementEnd(); - namespaceHTML(); + setHtmlNS(); elementEnd(); });