TypeScript @angular-compiler-src-schema-dom_element_schema_registry.DomElementSchemaRegistry类(方法)实例源码

下面列出了TypeScript @angular-compiler-src-schema-dom_element_schema_registry.DomElementSchemaRegistry 类(方法)源码代码实例,从而了解它的用法。

作者:AravindElangova    项目:angula   
describe('DOMElementSchema', () => {
    let registry: DomElementSchemaRegistry;
    beforeEach(() => { registry = new DomElementSchemaRegistry(); });

    it('should detect properties on regular elements', () => {
      expect(registry.hasProperty('div', 'id')).toBeTruthy();
      expect(registry.hasProperty('div', 'title')).toBeTruthy();
      expect(registry.hasProperty('h1', 'align')).toBeTruthy();
      expect(registry.hasProperty('h2', 'align')).toBeTruthy();
      expect(registry.hasProperty('h3', 'align')).toBeTruthy();
      expect(registry.hasProperty('h4', 'align')).toBeTruthy();
      expect(registry.hasProperty('h5', 'align')).toBeTruthy();
      expect(registry.hasProperty('h6', 'align')).toBeTruthy();
      expect(registry.hasProperty('h7', 'align')).toBeFalsy();
      expect(registry.hasProperty('textarea', 'disabled')).toBeTruthy();
      expect(registry.hasProperty('input', 'disabled')).toBeTruthy();
      expect(registry.hasProperty('div', 'unknown')).toBeFalsy();
    });

    it('should detect different kinds of types', () => {
      // inheritance: video => media => *
      expect(registry.hasProperty('video', 'className')).toBeTruthy();   // from *
      expect(registry.hasProperty('video', 'id')).toBeTruthy();          // string
      expect(registry.hasProperty('video', 'scrollLeft')).toBeTruthy();  // number
      expect(registry.hasProperty('video', 'height')).toBeTruthy();      // number
      expect(registry.hasProperty('video', 'autoplay')).toBeTruthy();    // boolean
      expect(registry.hasProperty('video', 'classList')).toBeTruthy();   // object
      // from *; but events are not properties
      expect(registry.hasProperty('video', 'click')).toBeFalsy();
    });

    it('should return true for custom-like elements',
       () => { expect(registry.hasProperty('custom-like', 'unknown')).toBeTruthy(); });

    it('should re-map property names that are specified in DOM facade',
       () => { expect(registry.getMappedPropName('readonly')).toEqual('readOnly'); });

    it('should not re-map property names that are not specified in DOM facade', () => {
      expect(registry.getMappedPropName('title')).toEqual('title');
      expect(registry.getMappedPropName('exotic-unknown')).toEqual('exotic-unknown');
    });

    it('should return security contexts for elements',
       () => { expect(registry.securityContext('a', 'href')).toBe(SecurityContext.URL); });

    it('should detect properties on namespaced elements',
       () => { expect(registry.hasProperty('@svg:g', 'id')).toBeTruthy(); });

    it('generate a new schema', () => {
      // console.log(JSON.stringify(registry.properties));
      extractSchema(
          (descriptors) => {
              // Uncomment this line to see:
              // the generated schema which can then be pasted to the DomElementSchemaRegistry
              // console.log(descriptors);
          });
    });
  });

作者:AmineAfi    项目:angula   
() => {
   // inheritance: video => media => *
   expect(registry.hasProperty('video', 'className')).toBeTruthy();   // from *
   expect(registry.hasProperty('video', 'id')).toBeTruthy();          // string
   expect(registry.hasProperty('video', 'scrollLeft')).toBeTruthy();  // number
   expect(registry.hasProperty('video', 'height')).toBeTruthy();      // number
   expect(registry.hasProperty('video', 'autoplay')).toBeTruthy();    // boolean
   expect(registry.hasProperty('video', 'classList')).toBeTruthy();   // object
   // from *; but events are not properties
   expect(registry.hasProperty('video', 'click')).toBeFalsy();
 })

作者:AurochsOfDoo    项目:angula   
it('should return security contexts for elements', () => {
   expect(registry.securityContext('iframe', 'srcdoc')).toBe(SecurityContext.HTML);
   expect(registry.securityContext('p', 'innerHTML')).toBe(SecurityContext.HTML);
   expect(registry.securityContext('a', 'href')).toBe(SecurityContext.URL);
   expect(registry.securityContext('a', 'style')).toBe(SecurityContext.STYLE);
   expect(registry.securityContext('ins', 'cite')).toBe(SecurityContext.URL);
   expect(registry.securityContext('base', 'href')).toBe(SecurityContext.RESOURCE_URL);
 });

作者:AmineAfi    项目:angula   
it('should not re-map property names that are not specified in DOM facade', () => {
   expect(registry.getMappedPropName('title')).toEqual('title');
   expect(registry.getMappedPropName('exotic-unknown')).toEqual('exotic-unknown');
 });

作者:SPG    项目:angula   
it('should return security contexts for elements', () => {
   expect(registry.securityContext('a', 'href')).toBe(SecurityContext.URL);
 });

作者:AravindElangova    项目:angula   
() => { expect(registry.securityContext('a', 'href')).toBe(SecurityContext.URL); });


问题


面经


文章

微信
公众号

扫码关注公众号