refactor(ivy): rename setNS, setHtmlNS and friends to namespace, namespaceHTML, etc (#23899)
- Renames functions - Adds documentation PR Close #23899
This commit is contained in:
parent
1208a35373
commit
0d06c866c6
|
@ -556,22 +556,38 @@ function getRenderFlags(view: LView): RenderFlags {
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
//// Namespace
|
//// Namespace
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
let _currentNS: string|null = null;
|
let _currentNamespace: string|null = null;
|
||||||
|
|
||||||
export function setNS(namespace: string) {
|
/**
|
||||||
_currentNS = namespace;
|
* 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 setHtmlNS() {
|
/**
|
||||||
_currentNS = null;
|
* 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 setSvgNS() {
|
/**
|
||||||
_currentNS = 'http://www.w3.org/2000/svg';
|
* 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 setMathML() {
|
* Sets the current namespace URI to http://www.w3.org/1998/Math/MathML, which will be
|
||||||
_currentNS = 'http://www.w3.org/1998/Math/MathML';
|
* used in conjunction with createElementNS in {@link element} and {@link elementStart}
|
||||||
|
*/
|
||||||
|
export function namespaceMathML() {
|
||||||
|
_currentNamespace = 'http://www.w3.org/1998/Math/MathML';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -599,9 +615,9 @@ export function elementStart(
|
||||||
|
|
||||||
ngDevMode && ngDevMode.rendererCreateElement++;
|
ngDevMode && ngDevMode.rendererCreateElement++;
|
||||||
|
|
||||||
const native: RElement = _currentNS === null || isProceduralRenderer(renderer) ?
|
const native: RElement = _currentNamespace === null || isProceduralRenderer(renderer) ?
|
||||||
renderer.createElement(name) :
|
renderer.createElement(name) :
|
||||||
(renderer as ObjectOrientedRenderer3).createElementNS(_currentNS, name);
|
(renderer as ObjectOrientedRenderer3).createElementNS(_currentNamespace, name);
|
||||||
|
|
||||||
ngDevMode && assertDataInRange(index - 1);
|
ngDevMode && assertDataInRange(index - 1);
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,7 @@
|
||||||
"name": "_currentInjector"
|
"name": "_currentInjector"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "_currentNS"
|
"name": "_currentNamespace"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "_devMode"
|
"name": "_devMode"
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {NgForOfContext} from '@angular/common';
|
||||||
|
|
||||||
import {RenderFlags, directiveInject} from '../../src/render3';
|
import {RenderFlags, directiveInject} from '../../src/render3';
|
||||||
import {defineComponent} from '../../src/render3/definition';
|
import {defineComponent} from '../../src/render3/definition';
|
||||||
import {bind, container, element, elementAttribute, elementClass, elementEnd, elementProperty, elementStart, elementStyle, elementStyleNamed, interpolation1, renderTemplate, setHtmlNS, setSvgNS, text, textBinding} from '../../src/render3/instructions';
|
import {bind, container, element, elementAttribute, elementClass, elementEnd, elementProperty, elementStart, elementStyle, elementStyleNamed, interpolation1, namespaceHTML, namespaceSVG, renderTemplate, text, textBinding} from '../../src/render3/instructions';
|
||||||
import {AttributeMarker, LElementNode, LNode} from '../../src/render3/interfaces/node';
|
import {AttributeMarker, LElementNode, LNode} from '../../src/render3/interfaces/node';
|
||||||
import {RElement, domRendererFactory3} from '../../src/render3/interfaces/renderer';
|
import {RElement, domRendererFactory3} from '../../src/render3/interfaces/renderer';
|
||||||
import {TrustedString, bypassSanitizationTrustHtml, bypassSanitizationTrustResourceUrl, bypassSanitizationTrustScript, bypassSanitizationTrustStyle, bypassSanitizationTrustUrl, sanitizeHtml, sanitizeResourceUrl, sanitizeScript, sanitizeStyle, sanitizeUrl} from '../../src/sanitization/sanitization';
|
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', () => {
|
it('should render SVG', () => {
|
||||||
const t = new TemplateFixture(() => {
|
const t = new TemplateFixture(() => {
|
||||||
elementStart(0, 'div', ['id', 'container']);
|
elementStart(0, 'div', ['id', 'container']);
|
||||||
setSvgNS();
|
namespaceSVG();
|
||||||
elementStart(1, 'svg', [
|
elementStart(1, 'svg', [
|
||||||
// id="display"
|
// id="display"
|
||||||
'id',
|
'id',
|
||||||
|
@ -452,7 +452,7 @@ describe('instructions', () => {
|
||||||
]);
|
]);
|
||||||
element(2, 'circle', ['cx', '200', 'cy', '150', 'fill', '#0000ff']);
|
element(2, 'circle', ['cx', '200', 'cy', '150', 'fill', '#0000ff']);
|
||||||
elementEnd();
|
elementEnd();
|
||||||
setHtmlNS();
|
namespaceHTML();
|
||||||
elementEnd();
|
elementEnd();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue