22import observable = require( "ui/core/dependency-observable" ) ;
33import cssParser = require( "css" ) ;
44import * as trace from "trace" ;
5- import * as styleProperty from "ui/styling/style-property" ;
5+ import { StyleProperty , ResolvedStylePropertyHandler , withStyleProperty } from "ui/styling/style-property" ;
66import * as types from "utils/types" ;
77import * as utils from "utils/utils" ;
88import keyframeAnimation = require( "ui/animation/keyframe-animation" ) ;
@@ -69,22 +69,24 @@ export class CssSelector {
6969 let modifier = valueSourceModifier || this . valueSourceModifier ;
7070 this . eachSetter ( ( property , value ) => {
7171 if ( types . isString ( property ) ) {
72+ const propertyName = < string > property ;
7273 let attrHandled = false ;
73- let specialSetter = getSpecialPropertySetter ( property ) ;
74+ let specialSetter = getSpecialPropertySetter ( propertyName ) ;
7475
7576 if ( ! attrHandled && specialSetter ) {
7677 specialSetter ( view , value ) ;
7778 attrHandled = true ;
7879 }
7980
80- if ( ! attrHandled && property in view ) {
81- view [ property ] = utils . convertString ( value ) ;
81+ if ( ! attrHandled && propertyName in view ) {
82+ view [ propertyName ] = utils . convertString ( value ) ;
8283 }
8384 } else {
85+ const resolvedProperty = < StyleProperty > property ;
8486 try {
85- view . style . _setValue ( property , value , modifier ) ;
87+ view . style . _setValue ( resolvedProperty , value , modifier ) ;
8688 } catch ( ex ) {
87- trace . write ( "Error setting property: " + property . name + " view: " + view + " value: " + value + " " + ex , trace . categories . Style , trace . messageType . error ) ;
89+ trace . write ( "Error setting property: " + resolvedProperty . name + " view: " + view + " value: " + value + " " + ex , trace . categories . Style , trace . messageType . error ) ;
8890 }
8991 }
9092 } ) ;
@@ -102,29 +104,12 @@ export class CssSelector {
102104 }
103105 }
104106
105- public eachSetter ( callback : ( property , resolvedValue : any ) => void ) {
107+ public eachSetter ( callback : ResolvedStylePropertyHandler ) {
106108 for ( let i = 0 ; i < this . _declarations . length ; i ++ ) {
107109 let declaration = this . _declarations [ i ] ;
108110 let name = declaration . property ;
109111 let resolvedValue = declaration . value ;
110-
111- let property = styleProperty . getPropertyByCssName ( name ) ;
112-
113- if ( property ) {
114- // The property.valueConverter is now used to convert the value later on in DependencyObservable._setValueInternal.
115- callback ( property , resolvedValue ) ;
116- }
117- else {
118- let pairs = styleProperty . getShorthandPairs ( name , resolvedValue ) ;
119- if ( pairs ) {
120- for ( let j = 0 ; j < pairs . length ; j ++ ) {
121- let pair = pairs [ j ] ;
122- callback ( pair . property , pair . value ) ;
123- }
124- } else {
125- callback ( declaration . property , declaration . value ) ;
126- }
127- }
112+ withStyleProperty ( name , resolvedValue , callback ) ;
128113 }
129114 }
130115
@@ -483,7 +468,8 @@ class InlineStyleSelector extends CssSelector {
483468
484469 public apply ( view : view . View ) {
485470 this . eachSetter ( ( property , value ) => {
486- view . style . _setValue ( property , value , observable . ValueSource . Local ) ;
471+ const resolvedProperty = < StyleProperty > property ;
472+ view . style . _setValue ( resolvedProperty , value , observable . ValueSource . Local ) ;
487473 } ) ;
488474 }
489475
0 commit comments