Revert "refactor(ivy): Use AttributeMarker instead of NS (#23899)"
This reverts commit 1208a35373
.
This commit is contained in:
parent
c151f9cdc8
commit
4f5b01a98a
|
@ -262,7 +262,7 @@ export function injectAttribute(attrNameToInject: string): string|undefined {
|
||||||
for (let i = 0; i < attrs.length; i = i + 2) {
|
for (let i = 0; i < attrs.length; i = i + 2) {
|
||||||
let attrName = attrs[i];
|
let attrName = attrs[i];
|
||||||
if (attrName === AttributeMarker.SELECT_ONLY) break;
|
if (attrName === AttributeMarker.SELECT_ONLY) break;
|
||||||
if (attrName === AttributeMarker.NAMESPACE_URI) {
|
if (attrName === 0) { // NS.FULL
|
||||||
attrName = attrs[i += 2];
|
attrName = attrs[i += 2];
|
||||||
}
|
}
|
||||||
if (attrName == attrNameToInject) {
|
if (attrName == attrNameToInject) {
|
||||||
|
|
|
@ -843,7 +843,8 @@ function setUpAttributes(native: RElement, attrs: TAttributes): void {
|
||||||
const isProc = isProceduralRenderer(renderer);
|
const isProc = isProceduralRenderer(renderer);
|
||||||
for (let i = 0; i < attrs.length; i += 2) {
|
for (let i = 0; i < attrs.length; i += 2) {
|
||||||
let attrName = attrs[i];
|
let attrName = attrs[i];
|
||||||
if (attrName === AttributeMarker.NAMESPACE_URI) {
|
if (attrName === 0) { // NS.FULL
|
||||||
|
// Namespaced attribute
|
||||||
const attrNS = attrs[i + 1] as string;
|
const attrNS = attrs[i + 1] as string;
|
||||||
attrName = attrs[i + 2] as string;
|
attrName = attrs[i + 2] as string;
|
||||||
const attrVal = attrs[i + 3] as string;
|
const attrVal = attrs[i + 3] as string;
|
||||||
|
@ -1515,7 +1516,7 @@ function generateInitialInputs(
|
||||||
const attrs = tNode.attrs !;
|
const attrs = tNode.attrs !;
|
||||||
for (let i = 0; i < attrs.length; i += 2) {
|
for (let i = 0; i < attrs.length; i += 2) {
|
||||||
const first = attrs[i];
|
const first = attrs[i];
|
||||||
const attrName = first === AttributeMarker.NAMESPACE_URI ? attrs[i += 2] : first;
|
const attrName = first === 0 ? attrs[i += 2] : first; // 0 = NS.FULL
|
||||||
const minifiedInputName = inputs[attrName];
|
const minifiedInputName = inputs[attrName];
|
||||||
const attrValue = attrs[i + 1];
|
const attrValue = attrs[i + 1];
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,18 @@ import {LQueries} from './query';
|
||||||
import {RElement, RNode, RText} from './renderer';
|
import {RElement, RNode, RText} from './renderer';
|
||||||
import {LView, TData, TView} from './view';
|
import {LView, TData, TView} from './view';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Namespace attribute flags.
|
||||||
|
*/
|
||||||
|
export const enum NS {
|
||||||
|
/**
|
||||||
|
* Use the next value as the full namespaces URI, the values after that
|
||||||
|
* are then the name and the value, respectively.
|
||||||
|
*/
|
||||||
|
FULL = 0,
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TNodeType corresponds to the TNode.type property. It contains information
|
* TNodeType corresponds to the TNode.type property. It contains information
|
||||||
* on how to map a particular set of bits in LNode.flags to the node type.
|
* on how to map a particular set of bits in LNode.flags to the node type.
|
||||||
|
@ -160,11 +172,7 @@ export interface LProjectionNode extends LNode {
|
||||||
* items are not regular attributes and the processing should be adapted accordingly.
|
* items are not regular attributes and the processing should be adapted accordingly.
|
||||||
*/
|
*/
|
||||||
export const enum AttributeMarker {
|
export const enum AttributeMarker {
|
||||||
/**
|
NS = 0, // namespace. Has to be repeated.
|
||||||
* Use the next value as the full namespaces URI, the values after that
|
|
||||||
* are then the name and the value, respectively.
|
|
||||||
*/
|
|
||||||
NAMESPACE_URI = 0, // namespace. Has to be repeated.
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This marker indicates that the following attribute names were extracted from bindings (ex.:
|
* This marker indicates that the following attribute names were extracted from bindings (ex.:
|
||||||
|
@ -180,7 +188,7 @@ export const enum AttributeMarker {
|
||||||
* - attribute names and values
|
* - attribute names and values
|
||||||
* - special markers acting as flags to alter attributes processing.
|
* - special markers acting as flags to alter attributes processing.
|
||||||
*/
|
*/
|
||||||
export type TAttributes = (string | AttributeMarker)[];
|
export type TAttributes = (string | AttributeMarker | NS)[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LNode binding data (flyweight) for a particular node that is shared between all templates
|
* LNode binding data (flyweight) for a particular node that is shared between all templates
|
||||||
|
|
|
@ -107,7 +107,8 @@ function findAttrIndexInNode(name: string, attrs: TAttributes | null): number {
|
||||||
if (attrs === null) return -1;
|
if (attrs === null) return -1;
|
||||||
for (let i = 0; i < attrs.length; i += step) {
|
for (let i = 0; i < attrs.length; i += step) {
|
||||||
const attrName = attrs[i];
|
const attrName = attrs[i];
|
||||||
if (attrName === AttributeMarker.NAMESPACE_URI) {
|
if (attrName === 0) {
|
||||||
|
// NS.FULL
|
||||||
step = 2;
|
step = 2;
|
||||||
} else if (attrName === name) {
|
} else if (attrName === name) {
|
||||||
return i;
|
return i;
|
||||||
|
|
|
@ -11,7 +11,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, renderTemplate, setHtmlNS, setSvgNS, text, textBinding} from '../../src/render3/instructions';
|
||||||
import {AttributeMarker, LElementNode, LNode} from '../../src/render3/interfaces/node';
|
import {LElementNode, LNode, NS} 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';
|
||||||
import {Sanitizer, SecurityContext} from '../../src/sanitization/security';
|
import {Sanitizer, SecurityContext} from '../../src/sanitization/security';
|
||||||
|
@ -95,7 +95,7 @@ describe('instructions', () => {
|
||||||
it('should use sanitizer function even on elements with namespaced attributes', () => {
|
it('should use sanitizer function even on elements with namespaced attributes', () => {
|
||||||
const t = new TemplateFixture(() => {
|
const t = new TemplateFixture(() => {
|
||||||
element(0, 'div', [
|
element(0, 'div', [
|
||||||
AttributeMarker.NAMESPACE_URI,
|
NS.FULL,
|
||||||
'http://www.example.com/2004/test',
|
'http://www.example.com/2004/test',
|
||||||
'whatever',
|
'whatever',
|
||||||
'abc',
|
'abc',
|
||||||
|
@ -445,7 +445,7 @@ describe('instructions', () => {
|
||||||
'height',
|
'height',
|
||||||
'300',
|
'300',
|
||||||
// test:title="abc"
|
// test:title="abc"
|
||||||
AttributeMarker.NAMESPACE_URI,
|
NS.FULL,
|
||||||
'http://www.example.com/2014/test',
|
'http://www.example.com/2014/test',
|
||||||
'title',
|
'title',
|
||||||
'abc',
|
'abc',
|
||||||
|
@ -472,7 +472,7 @@ describe('instructions', () => {
|
||||||
'id',
|
'id',
|
||||||
'container',
|
'container',
|
||||||
// test:title="abc"
|
// test:title="abc"
|
||||||
AttributeMarker.NAMESPACE_URI,
|
NS.FULL,
|
||||||
'http://www.example.com/2014/test',
|
'http://www.example.com/2014/test',
|
||||||
'title',
|
'title',
|
||||||
'abc',
|
'abc',
|
||||||
|
@ -492,7 +492,7 @@ describe('instructions', () => {
|
||||||
'container',
|
'container',
|
||||||
|
|
||||||
// NS1:title="abc"
|
// NS1:title="abc"
|
||||||
AttributeMarker.NAMESPACE_URI,
|
NS.FULL,
|
||||||
'http://www.example.com/2014/test',
|
'http://www.example.com/2014/test',
|
||||||
'title',
|
'title',
|
||||||
'abc',
|
'abc',
|
||||||
|
@ -502,13 +502,13 @@ describe('instructions', () => {
|
||||||
'background: #dead11',
|
'background: #dead11',
|
||||||
|
|
||||||
// NS1:whatever="wee"
|
// NS1:whatever="wee"
|
||||||
AttributeMarker.NAMESPACE_URI,
|
NS.FULL,
|
||||||
'http://www.example.com/2014/test',
|
'http://www.example.com/2014/test',
|
||||||
'whatever',
|
'whatever',
|
||||||
'wee',
|
'wee',
|
||||||
|
|
||||||
// NS2:shazbot="wocka wocka"
|
// NS2:shazbot="wocka wocka"
|
||||||
AttributeMarker.NAMESPACE_URI,
|
NS.FULL,
|
||||||
'http://www.whatever.com/2016/blah',
|
'http://www.whatever.com/2016/blah',
|
||||||
'shazbot',
|
'shazbot',
|
||||||
'wocka wocka',
|
'wocka wocka',
|
||||||
|
|
Loading…
Reference in New Issue