diff --git a/AppKit/CPButton.j b/AppKit/CPButton.j index 17d181a84..40fb82ee3 100644 --- a/AppKit/CPButton.j +++ b/AppKit/CPButton.j @@ -145,7 +145,7 @@ CPButtonStateMixed = CPThemeState("mixed"); + (id)themeAttributes { - return [CPDictionary dictionaryWithObjects:[_CGInsetMakeZero(), _CGInsetMakeZero(), nil] + return [CPDictionary dictionaryWithObjects:[_CGInsetMakeZero(), _CGInsetMakeZero(), [CPNull null]] forKeys:[@"bezel-inset", @"content-inset", @"bezel-color"]]; } diff --git a/AppKit/CPButtonBar.j b/AppKit/CPButtonBar.j index a66fb7b86..336829f4b 100644 --- a/AppKit/CPButtonBar.j +++ b/AppKit/CPButtonBar.j @@ -25,7 +25,7 @@ + (id)themeAttributes { - return [CPDictionary dictionaryWithObjects:[nil] + return [CPDictionary dictionaryWithObjects:[[CPNull null]] forKeys:[@"bezel-color"]]; } diff --git a/AppKit/CPControl.j b/AppKit/CPControl.j index 971996d0b..86c28a643 100644 --- a/AppKit/CPControl.j +++ b/AppKit/CPControl.j @@ -87,7 +87,7 @@ var CPControlBlackColor = [CPColor blackColor]; CPLineBreakByClipping, [CPColor blackColor], [CPFont systemFontOfSize:12.0], - nil, + [CPNull null], _CGSizeMakeZero(), CPImageLeft, CPScaleToFit, diff --git a/AppKit/CPScroller.j b/AppKit/CPScroller.j index 93e3c1a5d..dfd605788 100644 --- a/AppKit/CPScroller.j +++ b/AppKit/CPScroller.j @@ -79,7 +79,7 @@ NAMES_FOR_PARTS[CPScrollerKnob] = @"knob"; + (id)themeAttributes { - return [CPDictionary dictionaryWithObjects:[ nil, nil, nil, nil, + return [CPDictionary dictionaryWithObjects:[ [CPNull null], [CPNull null], [CPNull null], [CPNull null], _CGSizeMakeZero(), _CGSizeMakeZero(), _CGInsetMakeZero(), _CGInsetMakeZero(), _CGSizeMakeZero()] forKeys:[ @"knob-slot-color", @"decrement-line-color", diff --git a/AppKit/CPSegmentedControl.j b/AppKit/CPSegmentedControl.j index 9c680c21a..534a4e53d 100644 --- a/AppKit/CPSegmentedControl.j +++ b/AppKit/CPSegmentedControl.j @@ -56,7 +56,7 @@ CPSegmentSwitchTrackingMomentary = 2; + (id)themeAttributes { - return [CPDictionary dictionaryWithObjects:[CPCenterTextAlignment, CPCenterVerticalTextAlignment, CPImageLeft, CPScaleNone, _CGInsetMakeZero(), _CGInsetMakeZero(), nil, nil, nil, nil, 1.0, 24.0] + return [CPDictionary dictionaryWithObjects:[CPCenterTextAlignment, CPCenterVerticalTextAlignment, CPImageLeft, CPScaleNone, _CGInsetMakeZero(), _CGInsetMakeZero(), [CPNull null], [CPNull null], [CPNull null], [CPNull null], 1.0, 24.0] forKeys:[@"alignment", @"vertical-alignment", @"image-position", @"image-scaling", @"bezel-inset", @"content-inset", @"left-segment-bezel-color", @"right-segment-bezel-color", @"center-segment-bezel-color", @"divider-bezel-color", @"divider-thickness", @"default-height"]]; } diff --git a/AppKit/CPSlider.j b/AppKit/CPSlider.j index 6f5e764fd..1e96e75ee 100644 --- a/AppKit/CPSlider.j +++ b/AppKit/CPSlider.j @@ -49,7 +49,7 @@ CPCircularSlider = 1; + (id)themeAttributes { - return [CPDictionary dictionaryWithObjects:[nil, _CGSizeMakeZero(), 0.0, nil] + return [CPDictionary dictionaryWithObjects:[[CPNull null], _CGSizeMakeZero(), 0.0, [CPNull null]] forKeys:[@"knob-color", @"knob-size", @"track-width", @"track-color"]]; } diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 9373f039e..f5f43e5bf 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -161,7 +161,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); + (id)themeAttributes { - return [CPDictionary dictionaryWithObjects:[_CGInsetMakeZero(), _CGInsetMake(2.0, 2.0, 2.0, 2.0), nil] + return [CPDictionary dictionaryWithObjects:[_CGInsetMakeZero(), _CGInsetMake(2.0, 2.0, 2.0, 2.0), [CPNull null]] forKeys:[@"bezel-inset", @"content-inset", @"bezel-color"]]; } diff --git a/AppKit/CPView.j b/AppKit/CPView.j index a112d62ca..c0a2d87d2 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -2135,7 +2135,8 @@ setBoundsOrigin: var theClass = [self class], CPViewClass = [CPView class], - attributes = []; + attributes = [], + nullValue = [CPNull null]; for (; theClass && theClass !== CPViewClass; theClass = [theClass superclass]) { @@ -2159,9 +2160,10 @@ setBoundsOrigin: while (attributeCount--) { - var attributeName = attributeKeys[attributeCount]; + var attributeName = attributeKeys[attributeCount], + attributeValue = [attributeDictionary objectForKey:attributeName]; - attributes.push([attributeDictionary objectForKey:attributeName]); + attributes.push(attributeValue === nullValue ? nil : attributeValue); attributes.push(attributeName); } } diff --git a/AppKit/Themes/Aristo/ThemeDescriptors.j b/AppKit/Themes/Aristo/ThemeDescriptors.j index d709b2142..97b1a5c99 100644 --- a/AppKit/Themes/Aristo/ThemeDescriptors.j +++ b/AppKit/Themes/Aristo/ThemeDescriptors.j @@ -100,7 +100,7 @@ + (CPButton)themedStandardButton { var button = [self button]; - + [button setTitle:@"Cancel"]; return button; diff --git a/Foundation/CPArray.j b/Foundation/CPArray.j index d9ab4dd78..eeb8bad8b 100755 --- a/Foundation/CPArray.j +++ b/Foundation/CPArray.j @@ -817,7 +817,7 @@ description += '\n'; var object = [self objectAtIndex:index], - objectDescription = object && object.isa ? [object description] : object + ""; + objectDescription = object && object.isa ? [object description] : String(object); description += "\t" + objectDescription.split('\n').join("\n\t"); diff --git a/Foundation/CPAttributedString.j b/Foundation/CPAttributedString.j index b6bcb23cb..3b8fff5f8 100644 --- a/Foundation/CPAttributedString.j +++ b/Foundation/CPAttributedString.j @@ -638,7 +638,22 @@ */ - (void)removeAttribute:(CPString)anAttribute range:(CPRange)aRange { - [self addAttribute:anAttribute value:nil range:aRange]; + [self beginEditing]; + + var startingEntryIndex = [self _indexOfRangeEntryForIndex:aRange.location splitOnMaxIndex:YES], + endingEntryIndex = [self _indexOfRangeEntryForIndex:CPMaxRange(aRange) splitOnMaxIndex:YES], + current = startingEntryIndex; + + if (endingEntryIndex == CPNotFound) + endingEntryIndex = _rangeEntries.length; + + while (current < endingEntryIndex) + [_rangeEntries[current++].attributes removeObjectForKey:anAttribute]; + + //necessary? + [self _coalesceRangeEntriesFromIndex:startingEntryIndex toIndex:endingEntryIndex]; + + [self endEditing]; } //Changing Characters and Attributes diff --git a/Foundation/CPDictionary.j b/Foundation/CPDictionary.j index 189ad452d..fc162b2c7 100755 --- a/Foundation/CPDictionary.j +++ b/Foundation/CPDictionary.j @@ -364,7 +364,7 @@ if (lhsObject === rhsObject) continue; - if (lhsObject.isa && rhsObject.isa && [lhsObject respondsToSelector:@selector(isEqual:)] && [lhsObject isEqual:rhsObject]) + if (lhsObject && lhsObject.isa && rhsObject && rhsObject.isa && [lhsObject respondsToSelector:@selector(isEqual:)] && [lhsObject isEqual:rhsObject]) continue; return NO; diff --git a/Objective-J/CFDictionary.js b/Objective-J/CFDictionary.js index a0d49257c..a77645535 100644 --- a/Objective-J/CFDictionary.js +++ b/Objective-J/CFDictionary.js @@ -93,7 +93,7 @@ CFDictionary.prototype.valueForKey = function(/*String*/ aKey) var buckets = this._buckets; if (!hasOwnProperty.apply(buckets, [aKey])) - return undefined; + return nil; return buckets[aKey]; } @@ -109,7 +109,7 @@ CFDictionary.prototype.toString = function() { var key = keys[index]; - string += "\t" + key + " = \"" + this.valueForKey(key).toString().split('\n').join("\n\t") + "\"\n"; + string += "\t" + key + " = \"" + String(this.valueForKey(key)).split('\n').join("\n\t") + "\"\n"; } return string + "}"; @@ -143,7 +143,7 @@ CFMutableDictionary.prototype.removeValueForKey = function(/*String*/ aKey) var indexOfKey = -1; if (indexOf) - indexOfKey = this._keys.indexOf(aKey); + indexOfKey = indexOf.call(this._keys, aKey); else { var keys = this._keys, @@ -184,7 +184,10 @@ CFMutableDictionary.prototype.replaceValueForKey = function(/*String*/ aKey, /*O CFMutableDictionary.prototype.setValueForKey = function(/*String*/ aKey, /*Object*/ aValue) { - if (this.containsKey(aKey)) + if (aValue === nil || aValue === undefined) + this.removeValueForKey(aKey); + + else if (this.containsKey(aKey)) this.replaceValueForKey(aKey, aValue); else