style(lint): re-format modules/@angular
This commit is contained in:
@ -1,22 +1,11 @@
|
||||
import {
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
xdescribe,
|
||||
describe,
|
||||
expect,
|
||||
iit,
|
||||
inject,
|
||||
it,
|
||||
xit
|
||||
} from '@angular/core/testing/testing_internal';
|
||||
|
||||
import {HtmlParser} from '@angular/compiler/src/html_parser';
|
||||
import {HtmlElementAst} from '@angular/compiler/src/html_ast';
|
||||
|
||||
import {HtmlParser} from '@angular/compiler/src/html_parser';
|
||||
import {DomElementSchemaRegistry} from '@angular/compiler/src/schema/dom_element_schema_registry';
|
||||
import {beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {browserDetection} from '@angular/platform-browser/testing';
|
||||
|
||||
import {DomElementSchemaRegistry} from '@angular/compiler/src/schema/dom_element_schema_registry';
|
||||
import {SecurityContext} from '../../core_private';
|
||||
|
||||
import {extractSchema} from './schema_extractor';
|
||||
|
||||
export function main() {
|
||||
@ -73,7 +62,7 @@ export function main() {
|
||||
|
||||
it('should detect properties on namespaced elements', () => {
|
||||
let htmlAst = new HtmlParser().parse('<svg:style>', 'TestComp');
|
||||
let nodeName = (<HtmlElementAst>htmlAst.rootNodes[0]).name;
|
||||
let nodeName = (<HtmlElementAst>htmlAst.rootNodes[0]).name;
|
||||
expect(registry.hasProperty(nodeName, 'type')).toBeTruthy();
|
||||
});
|
||||
|
||||
@ -86,12 +75,10 @@ export function main() {
|
||||
if (browserDetection.isChromeDesktop) {
|
||||
it('generate a new schema', () => {
|
||||
let schema = '\n';
|
||||
extractSchema().forEach((props, name) => {
|
||||
schema += `'${name}|${props.join(',')}',\n`;
|
||||
});
|
||||
extractSchema().forEach((props, name) => { schema += `'${name}|${props.join(',')}',\n`; });
|
||||
// Uncomment this line to see:
|
||||
// the generated schema which can then be pasted to the DomElementSchemaRegistry
|
||||
//console.log(schema);
|
||||
// console.log(schema);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,17 @@
|
||||
import {isString, isPresent} from '../../src/facade/lang';
|
||||
import {isPresent, isString} from '../../src/facade/lang';
|
||||
|
||||
const SVG_PREFIX = ':svg:';
|
||||
|
||||
var document = typeof (global as any /** TODO #???? */)['document'] == 'object' ? (global as any /** TODO #???? */)['document'] : null;
|
||||
var document = typeof(global as any /** TODO #???? */)['document'] == 'object' ?
|
||||
(global as any /** TODO #???? */)['document'] :
|
||||
null;
|
||||
|
||||
export function extractSchema(): Map<string, string[]> {
|
||||
var SVGGraphicsElement = (global as any /** TODO #???? */)['SVGGraphicsElement'];
|
||||
var SVGAnimationElement = (global as any /** TODO #???? */)['SVGAnimationElement'];
|
||||
var SVGGeometryElement = (global as any /** TODO #???? */)['SVGGeometryElement'];
|
||||
var SVGComponentTransferFunctionElement = (global as any /** TODO #???? */)['SVGComponentTransferFunctionElement'];
|
||||
var SVGComponentTransferFunctionElement =
|
||||
(global as any /** TODO #???? */)['SVGComponentTransferFunctionElement'];
|
||||
var SVGGradientElement = (global as any /** TODO #???? */)['SVGGradientElement'];
|
||||
var SVGTextContentElement = (global as any /** TODO #???? */)['SVGTextContentElement'];
|
||||
var SVGTextPositioningElement = (global as any /** TODO #???? */)['SVGTextPositioningElement'];
|
||||
@ -27,44 +30,47 @@ export function extractSchema(): Map<string, string[]> {
|
||||
extractProperties(HTMLElement, element, visited, descMap, '', '*');
|
||||
extractProperties(HTMLMediaElement, element, visited, descMap, 'media', '');
|
||||
extractProperties(SVGElement, svgText, visited, descMap, SVG_PREFIX, '*');
|
||||
extractProperties(SVGGraphicsElement, svgText, visited, descMap, SVG_PREFIX + 'graphics',
|
||||
SVG_PREFIX);
|
||||
extractProperties(SVGAnimationElement, svgAnimation, visited, descMap,
|
||||
SVG_PREFIX + 'animation', SVG_PREFIX);
|
||||
extractProperties(SVGGeometryElement, svgPath, visited, descMap, SVG_PREFIX + 'geometry',
|
||||
SVG_PREFIX);
|
||||
extractProperties(SVGComponentTransferFunctionElement, svgFeFuncA, visited, descMap,
|
||||
SVG_PREFIX + 'componentTransferFunction', SVG_PREFIX);
|
||||
extractProperties(SVGGradientElement, svgGradient, visited, descMap, SVG_PREFIX + 'gradient',
|
||||
SVG_PREFIX);
|
||||
extractProperties(SVGTextContentElement, svgText, visited, descMap,
|
||||
SVG_PREFIX + 'textContent', SVG_PREFIX + 'graphics');
|
||||
extractProperties(SVGTextPositioningElement, svgText, visited, descMap,
|
||||
SVG_PREFIX + 'textPositioning', SVG_PREFIX + 'textContent');
|
||||
extractProperties(
|
||||
SVGGraphicsElement, svgText, visited, descMap, SVG_PREFIX + 'graphics', SVG_PREFIX);
|
||||
extractProperties(
|
||||
SVGAnimationElement, svgAnimation, visited, descMap, SVG_PREFIX + 'animation', SVG_PREFIX);
|
||||
extractProperties(
|
||||
SVGGeometryElement, svgPath, visited, descMap, SVG_PREFIX + 'geometry', SVG_PREFIX);
|
||||
extractProperties(
|
||||
SVGComponentTransferFunctionElement, svgFeFuncA, visited, descMap,
|
||||
SVG_PREFIX + 'componentTransferFunction', SVG_PREFIX);
|
||||
extractProperties(
|
||||
SVGGradientElement, svgGradient, visited, descMap, SVG_PREFIX + 'gradient', SVG_PREFIX);
|
||||
extractProperties(
|
||||
SVGTextContentElement, svgText, visited, descMap, SVG_PREFIX + 'textContent',
|
||||
SVG_PREFIX + 'graphics');
|
||||
extractProperties(
|
||||
SVGTextPositioningElement, svgText, visited, descMap, SVG_PREFIX + 'textPositioning',
|
||||
SVG_PREFIX + 'textContent');
|
||||
var keys = Object.getOwnPropertyNames(window).filter(
|
||||
k => k.endsWith('Element') && (k.startsWith('HTML') || k.startsWith('SVG')));
|
||||
keys.sort();
|
||||
keys.forEach(name => extractRecursiveProperties(visited, descMap, (window as any /** TODO #???? */)[name]));
|
||||
keys.forEach(
|
||||
name =>
|
||||
extractRecursiveProperties(visited, descMap, (window as any /** TODO #???? */)[name]));
|
||||
|
||||
return descMap;
|
||||
}
|
||||
|
||||
function extractRecursiveProperties(visited: {[name: string]: boolean}, descMap: Map<string, string[]>,
|
||||
type: Function): string {
|
||||
function extractRecursiveProperties(
|
||||
visited: {[name: string]: boolean}, descMap: Map<string, string[]>, type: Function): string {
|
||||
var name = extractName(type);
|
||||
if (visited[name]) return name; // already been here
|
||||
var superName = '';
|
||||
if (name != '*') {
|
||||
superName =
|
||||
extractRecursiveProperties(visited, descMap, type.prototype.__proto__.constructor);
|
||||
superName = extractRecursiveProperties(visited, descMap, type.prototype.__proto__.constructor);
|
||||
}
|
||||
|
||||
var instance: HTMLElement = null;
|
||||
name.split(',').forEach(tagName => {
|
||||
instance = isSVG(type) ?
|
||||
document.createElementNS('http://www.w3.org/2000/svg',
|
||||
tagName.replace(SVG_PREFIX, '')) :
|
||||
document.createElement(tagName);
|
||||
document.createElementNS('http://www.w3.org/2000/svg', tagName.replace(SVG_PREFIX, '')) :
|
||||
document.createElement(tagName);
|
||||
var htmlType = type;
|
||||
if (tagName == 'cite') htmlType = HTMLElement;
|
||||
if (!(instance instanceof htmlType)) {
|
||||
@ -75,8 +81,9 @@ function extractRecursiveProperties(visited: {[name: string]: boolean}, descMap:
|
||||
return name;
|
||||
}
|
||||
|
||||
function extractProperties(type: Function, instance: any, visited: {[name: string]: boolean},
|
||||
descMap: Map<string, string[]>, name: string, superName: string) {
|
||||
function extractProperties(
|
||||
type: Function, instance: any, visited: {[name: string]: boolean},
|
||||
descMap: Map<string, string[]>, name: string, superName: string) {
|
||||
if (!type) return;
|
||||
visited[name] = true;
|
||||
const fullName = name + (superName ? '^' + superName : '');
|
||||
|
Reference in New Issue
Block a user