Revert "feat(ivy): added new namespace and element instructions to JIT environment (#23899)"

This reverts commit acf270d724.
This commit is contained in:
Victor Berchet
2018-06-06 13:38:00 -07:00
parent 9dd647b087
commit 7e73287676
18 changed files with 75 additions and 126 deletions

View File

@ -45,6 +45,7 @@ export {
i7 as ɵi7,
i8 as ɵi8,
iV as ɵiV,
N as ɵN,
NH as ɵNH,
NM as ɵNM,
NS as ɵNS,

View File

@ -150,7 +150,7 @@ The goal is for the `@Component` (and friends) to be the compiler of template. S
| `{{ ['literal', exp ] }}` | ✅ | ✅ | ✅ |
| `{{ { a: 'literal', b: exp } }}` | ✅ | ✅ | ✅ |
| `{{ exp \| pipe: arg }}` | ✅ | ✅ | ✅ |
| `<svg:g svg:p>` | ✅ | ✅ | |
| `<svg:g svg:p>` | ✅ | ✅ | |
| `<img src=[userData]>` sanitization | ❌ | ❌ | ❌ |
| `<div (nocd.click)>` | ❌ | ❌ | ❌ |
| `<div (bubble.click)>` | ❌ | ❌ | ❌ |

View File

@ -261,8 +261,8 @@ export function injectAttribute(attrNameToInject: string): string|undefined {
if (attrs) {
for (let i = 0; i < attrs.length; i = i + 2) {
let attrName = attrs[i];
if (attrName === AttributeMarker.SelectOnly) break;
if (attrName === AttributeMarker.NamespaceUri) {
if (attrName === AttributeMarker.SELECT_ONLY) break;
if (attrName === AttributeMarker.NAMESPACE_URI) {
attrName = attrs[i += 2];
}
if (attrName == attrNameToInject) {

View File

@ -54,6 +54,7 @@ export {
elementStyle as s,
elementStyleNamed as sn,
namespace as N,
namespaceHTML as NH,
namespaceMathML as NM,
namespaceSVG as NS,

View File

@ -560,6 +560,15 @@ function getRenderFlags(view: LView): RenderFlags {
//////////////////////////
let _currentNamespace: 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;
}
/**
* Sets the current namespace URI to null, meaning createElement (not createElementNS)
* will be used to create elements in {@link element} and {@link elementStart}
@ -608,17 +617,9 @@ export function elementStart(
ngDevMode && ngDevMode.rendererCreateElement++;
let native: RElement;
if (isProceduralRenderer(renderer)) {
native = renderer.createElement(name, _currentNamespace);
} else {
if (_currentNamespace === null) {
native = renderer.createElement(name);
} else {
native = renderer.createElementNS(_currentNamespace, name);
}
}
const native: RElement = _currentNamespace === null || isProceduralRenderer(renderer) ?
renderer.createElement(name) :
(renderer as ObjectOrientedRenderer3).createElementNS(_currentNamespace, name);
ngDevMode && assertDataInRange(index - 1);
@ -860,7 +861,7 @@ function setUpAttributes(native: RElement, attrs: TAttributes): void {
const isProc = isProceduralRenderer(renderer);
for (let i = 0; i < attrs.length; i += 2) {
let attrName = attrs[i];
if (attrName === AttributeMarker.NamespaceUri) {
if (attrName === AttributeMarker.NAMESPACE_URI) {
const attrNS = attrs[i + 1] as string;
attrName = attrs[i + 2] as string;
const attrVal = attrs[i + 3] as string;
@ -871,7 +872,7 @@ function setUpAttributes(native: RElement, attrs: TAttributes): void {
native.setAttributeNS(attrNS, attrName, attrVal);
}
} else {
if (attrName === AttributeMarker.SelectOnly) break;
if (attrName === AttributeMarker.SELECT_ONLY) break;
if (attrName !== NG_PROJECT_AS_ATTR_NAME) {
const attrVal = attrs[i + 1];
ngDevMode && ngDevMode.rendererSetAttribute++;
@ -1532,11 +1533,11 @@ function generateInitialInputs(
const attrs = tNode.attrs !;
for (let i = 0; i < attrs.length; i += 2) {
const first = attrs[i];
const attrName = first === AttributeMarker.NamespaceUri ? attrs[i += 2] : first;
const attrName = first === AttributeMarker.NAMESPACE_URI ? attrs[i += 2] : first;
const minifiedInputName = inputs[attrName];
const attrValue = attrs[i + 1];
if (attrName === AttributeMarker.SelectOnly) break;
if (attrName === AttributeMarker.SELECT_ONLY) break;
if (minifiedInputName !== undefined) {
const inputsToStore: InitialInputs =
initialInputData[directiveIndex] || (initialInputData[directiveIndex] = []);

View File

@ -164,7 +164,7 @@ export const enum AttributeMarker {
* Use the next value as the full namespaces URI, the values after that
* are then the name and the value, respectively.
*/
NamespaceUri = 0, // namespace. Has to be repeated.
NAMESPACE_URI = 0, // namespace. Has to be repeated.
/**
* This marker indicates that the following attribute names were extracted from bindings (ex.:
@ -172,7 +172,7 @@ export const enum AttributeMarker {
* Taking the above bindings and outputs as an example an attributes array could look as follows:
* ['class', 'fade in', AttributeMarker.SELECT_ONLY, 'foo', 'bar']
*/
SelectOnly = 1
SELECT_ONLY = 1
}
/**

View File

@ -37,7 +37,6 @@ export const angularCoreEnv: {[name: string]: Function} = {
'ɵcr': r3.cr,
'ɵd': r3.d,
'ɵE': r3.E,
'ɵEe': r3.Ee,
'ɵe': r3.e,
'ɵf0': r3.f0,
'ɵf1': r3.f1,
@ -61,9 +60,6 @@ export const angularCoreEnv: {[name: string]: Function} = {
'ɵkn': r3.kn,
'ɵL': r3.L,
'ɵld': r3.ld,
'ɵNH': r3.NH,
'ɵNM': r3.NM,
'ɵNS': r3.NS,
'ɵp': r3.p,
'ɵpb1': r3.pb1,
'ɵpb2': r3.pb2,

View File

@ -41,7 +41,7 @@ export function isNodeMatchingSelector(tNode: TNode, selector: CssSelector): boo
let mode: SelectorFlags = SelectorFlags.ELEMENT;
const nodeAttrs = tNode.attrs !;
const selectOnlyMarkerIdx = nodeAttrs ? nodeAttrs.indexOf(AttributeMarker.SelectOnly) : -1;
const selectOnlyMarkerIdx = nodeAttrs ? nodeAttrs.indexOf(AttributeMarker.SELECT_ONLY) : -1;
// When processing ":not" selectors, we skip to the next ":not" if the
// current one doesn't match
@ -107,11 +107,11 @@ function findAttrIndexInNode(name: string, attrs: TAttributes | null): number {
if (attrs === null) return -1;
for (let i = 0; i < attrs.length; i += step) {
const attrName = attrs[i];
if (attrName === AttributeMarker.NamespaceUri) {
if (attrName === AttributeMarker.NAMESPACE_URI) {
step = 2;
} else if (attrName === name) {
return i;
} else if (attrName === AttributeMarker.SelectOnly) {
} else if (attrName === AttributeMarker.SELECT_ONLY) {
step = 1;
}
}