11import { int , isPresent , isBlank , Type , BaseException , StringWrapper , RegExpWrapper , isString , stringify } from 'angular2/src/facade/lang' ;
2- import { Element , DOM , attrToPropMap } from 'angular2/src/facade/ dom' ;
2+ import { DOM } from 'angular2/src/dom/dom_adapter ' ;
33import { ListWrapper , List , MapWrapper , StringMapWrapper } from 'angular2/src/facade/collection' ;
44
55import { reflector } from 'angular2/src/reflection/reflection' ;
@@ -21,7 +21,7 @@ function ariaSetterFactory(attrName:string) {
2121 var setterFn = StringMapWrapper . get ( ariaSettersCache , attrName ) ;
2222
2323 if ( isBlank ( setterFn ) ) {
24- setterFn = function ( element : Element , value ) {
24+ setterFn = function ( element , value ) {
2525 if ( isPresent ( value ) ) {
2626 DOM . setAttribute ( element , attrName , stringify ( value ) ) ;
2727 } else {
@@ -42,7 +42,7 @@ function classSetterFactory(className:string) {
4242 var setterFn = StringMapWrapper . get ( classSettersCache , className ) ;
4343
4444 if ( isBlank ( setterFn ) ) {
45- setterFn = function ( element : Element , value ) {
45+ setterFn = function ( element , value ) {
4646 if ( value ) {
4747 DOM . addClass ( element , className ) ;
4848 } else {
@@ -64,7 +64,7 @@ function styleSetterFactory(styleName:string, stylesuffix:string) {
6464 var setterFn = StringMapWrapper . get ( styleSettersCache , cacheKey ) ;
6565
6666 if ( isBlank ( setterFn ) ) {
67- setterFn = function ( element : Element , value ) {
67+ setterFn = function ( element , value ) {
6868 var valAsStr ;
6969 if ( isPresent ( value ) ) {
7070 valAsStr = stringify ( value ) ;
@@ -80,7 +80,7 @@ function styleSetterFactory(styleName:string, stylesuffix:string) {
8080}
8181
8282const ROLE_ATTR = 'role' ;
83- function roleSetter ( element : Element , value ) {
83+ function roleSetter ( element , value ) {
8484 if ( isString ( value ) ) {
8585 DOM . setAttribute ( element , ROLE_ATTR , value ) ;
8686 } else {
@@ -92,18 +92,25 @@ function roleSetter(element:Element, value) {
9292}
9393
9494// special mapping for cases where attribute name doesn't match property name
95- var attrToProp = StringMapWrapper . merge ( {
96- "inner-html" : "innerHTML" ,
97- "readonly" : "readOnly" ,
98- "tabindex" : "tabIndex" ,
99- } , attrToPropMap ) ;
95+ var _lazyAttrToProp ;
96+
97+ function attrToProp ( ) {
98+ if ( ! isPresent ( _lazyAttrToProp ) ) {
99+ _lazyAttrToProp = StringMapWrapper . merge ( {
100+ "inner-html" : "innerHTML" ,
101+ "readonly" : "readOnly" ,
102+ "tabindex" : "tabIndex" ,
103+ } , DOM . attrToPropMap ) ;
104+ }
105+ return _lazyAttrToProp ;
106+ }
100107
101108// tells if an attribute is handled by the ElementBinderBuilder step
102109export function isSpecialProperty ( propName :string ) {
103110 return StringWrapper . startsWith ( propName , ARIA_PREFIX )
104111 || StringWrapper . startsWith ( propName , CLASS_PREFIX )
105112 || StringWrapper . startsWith ( propName , STYLE_PREFIX )
106- || StringMapWrapper . contains ( attrToProp , propName ) ;
113+ || StringMapWrapper . contains ( attrToProp ( ) , propName ) ;
107114}
108115
109116/**
@@ -250,7 +257,7 @@ export class ElementBinderBuilder extends CompileStep {
250257 }
251258
252259 _resolvePropertyName ( attrName :string ) {
253- var mappedPropName = StringMapWrapper . get ( attrToProp , attrName ) ;
260+ var mappedPropName = StringMapWrapper . get ( attrToProp ( ) , attrName ) ;
254261 return isPresent ( mappedPropName ) ? mappedPropName : attrName ;
255262 }
256263}
0 commit comments