mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-19 00:43:29 +00:00
several bindings / KVC fixes
- setValue:forKeyPath will now get call setValue:forKeyPath again on the value of the first part of the key path - override valueForKeyPath: and valueForKey: in CPObjectController's CPControllerSelectionProxy to return controller markers when appropriate - override setValue:forKeyPath: and setValue:forKey: in CPObjectController's CPControllerSelectionProxy to bypass possible controller markers This commit also removes previous hacks for compound paths and adds test cases for the errors. All this is related to issue #967.
This commit is contained in:
@@ -178,9 +178,6 @@ var CPObjectAccessorsForClassKey = @"$CPObjectAccessorsForClassKey",
|
||||
remainingKeyPath = aKeyPath.substring(firstDotIndex + 1),
|
||||
value = [self valueForKey:firstKeyComponent];
|
||||
|
||||
if (CPIsControllerMarker(value))
|
||||
return value;
|
||||
|
||||
return [value valueForKeyPath:remainingKeyPath];
|
||||
}
|
||||
|
||||
@@ -213,24 +210,18 @@ var CPObjectAccessorsForClassKey = @"$CPObjectAccessorsForClassKey",
|
||||
|
||||
- (void)setValue:(id)aValue forKeyPath:(CPString)aKeyPath
|
||||
{
|
||||
if (!aKeyPath) aKeyPath = "self";
|
||||
if (!aKeyPath) aKeyPath = @"self";
|
||||
|
||||
var i = 0,
|
||||
keys = aKeyPath.split("."),
|
||||
count = keys.length - 1,
|
||||
owner = self;
|
||||
var firstDotIndex = aKeyPath.indexOf(".");
|
||||
|
||||
for (; i < count; ++i)
|
||||
{
|
||||
var newOwner = [owner valueForKey:keys[i]];
|
||||
if (firstDotIndex === -1)
|
||||
return [self setValue:aValue forKey:aKeyPath];
|
||||
|
||||
if (CPIsControllerMarker(newOwner))
|
||||
newOwner = [owner _valueForKey:keys[i]];
|
||||
var firstKeyComponent = aKeyPath.substring(0, firstDotIndex),
|
||||
remainingKeyPath = aKeyPath.substring(firstDotIndex + 1),
|
||||
value = [self valueForKey:firstKeyComponent];
|
||||
|
||||
owner = newOwner;
|
||||
}
|
||||
|
||||
[owner setValue:aValue forKey:keys[i]];
|
||||
return [value setValue:aValue forKeyPath:remainingKeyPath];
|
||||
}
|
||||
|
||||
- (void)setValue:(id)aValue forKey:(CPString)aKey
|
||||
|
||||
Reference in New Issue
Block a user