| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -455,6 +455,17 @@ export function test_parse_ShouldParseSubProperties() { | |||
| 455 | 455 | TKUnit.assert(sw.visibility === "collapsed", "Expected result: collapsed; Actual result: " + sw.visibility + "; type: " + typeof (sw.visibility)); | |
| 456 | 456 | }; | |
| 457 | 457 | ||
| 458 | + export function test_parse_ShouldParseBindingToSpecialProperty() { | ||
| 459 | + var classProp = "MyClass"; | ||
| 460 | + var p = <Page>builder.parse("<Page><Label class='{{ myProp }}' /></Page>"); | ||
| 461 | + var obj = new observable.Observable(); | ||
| 462 | + obj.set("myProp", classProp); | ||
| 463 | + p.bindingContext = obj; | ||
| 464 | + | ||
| 465 | + TKUnit.assertEqual(p.content.className, classProp); | ||
| 466 | + TKUnit.assertEqual(p.content._cssClasses.length, 1); | ||
| 467 | + }; | ||
| 468 | + | ||
| 458 | 469 | export function test_parse_ShouldParseBindingsWithCommaInsideSingleQuote() { | |
| 459 | 470 | var expected = "Hi,test" | |
| 460 | 471 | var bindingString = "{{ 'Hi,' + myProp }}"; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,7 @@ import trace = require("trace"); | |||
| 7 | 7 | import polymerExpressions = require("js-libs/polymer-expressions"); | |
| 8 | 8 | import bindingBuilder = require("../builder/binding-builder"); | |
| 9 | 9 | import viewModule = require("ui/core/view"); | |
| 10 | + import {getSpecialPropertySetter} from "ui/builder/special-properties"; | ||
| 10 | 11 | ||
| 11 | 12 | //late import | |
| 12 | 13 | var _appModule = null; | |
@@ -22,7 +23,7 @@ var bindingContextProperty = new dependencyObservable.Property( | |||
| 22 | 23 | "bindingContext", | |
| 23 | 24 | "Bindable", | |
| 24 | 25 | new dependencyObservable.PropertyMetadata(undefined, dependencyObservable.PropertyMetadataSettings.Inheritable, onBindingContextChanged) | |
| 25 | - ); | ||
| 26 | + ); | ||
| 26 | 27 | ||
| 27 | 28 | function onBindingContextChanged(data: dependencyObservable.PropertyChangeData) { | |
| 28 | 29 | var bindable = <Bindable>data.object; | |
@@ -211,8 +212,8 @@ export class Binding { | |||
| 211 | 212 | // then split properties either on '.' or '[' | |
| 212 | 213 | var parentsMatches = property.match(bindingBuilder.parentsRegex); | |
| 213 | 214 | result = property.replace(bindingBuilder.parentsRegex, "parentsMatch") | |
| 214 | - .replace(/\]/g, "") | ||
| 215 | - .split(/\.|\[/); | ||
| 215 | + .replace(/\]/g, "") | ||
| 216 | + .split(/\.|\[/); | ||
| 216 | 217 | ||
| 217 | 218 | var i; | |
| 218 | 219 | var resultLength = result.length; | |
@@ -591,10 +592,15 @@ export class Binding { | |||
| 591 | 592 | optionsInstance.off(options.property, null, optionsInstance.bindingContext); | |
| 592 | 593 | optionsInstance.on(options.property, value, optionsInstance.bindingContext); | |
| 593 | 594 | } else { | |
| 594 | - if (optionsInstance instanceof observable.Observable) { | ||
| 595 | - optionsInstance.set(options.property, value); | ||
| 595 | + let specialSetter = getSpecialPropertySetter(options.property); | ||
| 596 | + if (specialSetter) { | ||
| 597 | + specialSetter(optionsInstance, value); | ||
| 596 | 598 | } else { | |
| 597 | - optionsInstance[options.property] = value; | ||
| 599 | + if (optionsInstance instanceof observable.Observable) { | ||
| 600 | + optionsInstance.set(options.property, value); | ||
| 601 | + } else { | ||
| 602 | + optionsInstance[options.property] = value; | ||
| 603 | + } | ||
| 598 | 604 | } | |
| 599 | 605 | } | |
| 600 | 606 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments