From 7dc77ed609bfa8112201260d9106fc69d7ae0484 Mon Sep 17 00:00:00 2001 From: Martin Carlberg Date: Fri, 31 Jan 2020 13:43:58 +0100 Subject: [PATCH] Fixed: Make sure we handle undefined when testing for nil values (#2862) --- AppKit/CPArrayController.j | 8 ++-- AppKit/CPButton.j | 2 +- AppKit/CPCollectionView.j | 2 +- AppKit/CPComboBox.j | 2 +- AppKit/CPControl.j | 16 ++++---- AppKit/CPDictionaryController.j | 4 +- AppKit/CPDocumentController.j | 2 +- AppKit/CPEvent.j | 2 +- AppKit/CPFlashView.j | 4 +- AppKit/CPFontManager.j | 2 +- AppKit/CPImage.j | 4 +- AppKit/CPKeyValueBinding.j | 6 +-- AppKit/CPMenu/CPMenu.j | 2 +- AppKit/CPMenu/_CPMenuManager.j | 4 +- AppKit/CPObjectController.j | 4 +- AppKit/CPOutlineView.j | 4 +- AppKit/CPResponder.j | 2 +- AppKit/CPRuleEditor/CPRuleEditor.j | 40 +++++++++---------- .../CPRuleEditor/_CPPredicateEditorRowNode.j | 2 +- AppKit/CPRuleEditor/_CPRuleEditorLocalizer.j | 8 ++-- AppKit/CPScrollView.j | 4 +- AppKit/CPSearchField.j | 12 +++--- AppKit/CPSplitView.j | 2 +- AppKit/CPTabView.j | 12 +++--- AppKit/CPTableColumn.j | 2 +- AppKit/CPTableView.j | 18 ++++----- AppKit/CPTextField.j | 10 ++--- AppKit/CPTextView/CPFontPanel.j | 2 +- AppKit/CPTextView/CPTextView.j | 4 +- AppKit/CPTextView/_CPRTFProducer.j | 4 +- AppKit/CPTheme.j | 12 +++--- AppKit/CPTokenField.j | 12 +++--- AppKit/CPToolbar.j | 2 +- AppKit/CPTrackingArea.j | 14 +++---- AppKit/CPUserDefaultsController.j | 8 ++-- AppKit/CPView.j | 18 ++++----- AppKit/CPViewController.j | 6 +-- AppKit/CPWebView.j | 6 +-- AppKit/CPWindow/CPWindow.j | 2 +- AppKit/CPWindow/_CPWindowView.j | 2 +- AppKit/CPWindowController.j | 4 +- AppKit/Cib/CPCib.j | 2 +- AppKit/Cib/_CPCibObjectData.j | 2 +- AppKit/CoreAnimation/CPViewAnimator.j | 2 +- AppKit/CoreAnimation/_CPObjectAnimator.j | 2 +- AppKit/CoreGraphics/CGContext.j | 4 +- AppKit/CoreGraphics/CGContextCanvas.j | 8 ++-- AppKit/CoreGraphics/CGGradient.j | 4 +- AppKit/CoreGraphics/CGPath.j | 4 +- AppKit/Platform/DOM/CPPlatform.j | 2 +- AppKit/_CPImageAndTextView.j | 2 +- AppKit/_CPPopUpList.j | 2 +- AppKit/_CPPopoverWindow.j | 2 +- CONTRIBUTING.md | 10 ++--- Foundation/CPArray+KVO.j | 12 +++--- Foundation/CPArray/CPMutableArray.j | 6 +-- Foundation/CPArray/_CPArray.j | 2 +- Foundation/CPArray/_CPJavaScriptArray.j | 2 +- Foundation/CPAttributedString.j | 2 +- Foundation/CPCharacterSet.j | 4 +- Foundation/CPDictionary.j | 20 +++++----- Foundation/CPFormatter.j | 2 +- Foundation/CPKeyValueCoding.j | 6 +-- Foundation/CPKeyValueObserving.j | 4 +- Foundation/CPKeyedArchiver.j | 18 ++++----- Foundation/CPKeyedUnarchiver.j | 6 +-- Foundation/CPNotificationCenter.j | 14 +++---- Foundation/CPNumber.j | 2 +- Foundation/CPNumberFormatter.j | 4 +- .../CPPredicate/CPComparisonPredicate.j | 4 +- Foundation/CPPredicate/CPCompoundPredicate.j | 2 +- .../CPPredicate/_CPAggregateExpression.j | 4 +- Foundation/CPPredicate/_CPBlockExpression.j | 2 +- .../CPPredicate/_CPConditionalExpression.j | 2 +- .../CPPredicate/_CPConstantValueExpression.j | 2 +- .../CPPredicate/_CPFunctionExpression.j | 2 +- Foundation/CPPredicate/_CPKeyPathExpression.j | 2 +- Foundation/CPPredicate/_CPPredicate.j | 2 +- Foundation/CPPredicate/_CPSetExpression.j | 2 +- .../CPPredicate/_CPSubqueryExpression.j | 2 +- .../CPPredicate/_CPVariableExpression.j | 2 +- Foundation/CPRunLoop.j | 8 ++-- Foundation/CPSet+KVO.j | 16 ++++---- Foundation/CPSet/CPMutableSet.j | 10 ++--- Foundation/CPSet/_CPConcreteMutableSet.j | 6 +-- Foundation/CPSet/_CPSet.j | 18 ++++----- Foundation/CPString.j | 2 +- Foundation/CPURLConnection.j | 8 ++-- Foundation/CPUndoManager.j | 4 +- Foundation/CPUserDefaults.j | 6 +-- Foundation/CPValueTransformer.j | 4 +- Foundation/CPWebDAVManager.j | 4 +- Foundation/_CPCollectionKVCOperators.j | 12 +++--- Objective-J/CFDictionary.js | 2 +- Tests/AppKit/CPNotificationCenterHelper.j | 6 +-- 95 files changed, 280 insertions(+), 280 deletions(-) diff --git a/AppKit/CPArrayController.j b/AppKit/CPArrayController.j index 0201dcd0d..484fdecd5 100644 --- a/AppKit/CPArrayController.j +++ b/AppKit/CPArrayController.j @@ -271,7 +271,7 @@ if (_disableSetContent) return; - if (value === nil) + if (value == nil) value = []; if (![value isKindOfClass:[CPArray class]]) @@ -754,7 +754,7 @@ _filterPredicate = nil; [self _rearrangeObjects]; } - else if (_filterPredicate === nil || [_filterPredicate evaluateWithObject:object]) + else if (_filterPredicate == nil || [_filterPredicate evaluateWithObject:object]) { // Insert directly into the array. var pos = [_arrangedObjects insertObject:object inArraySortedByDescriptors:_sortDescriptors]; @@ -767,7 +767,7 @@ [_selectionIndexes shiftIndexesStartingAtIndex:pos by:1]; } /* - else if (_filterPredicate !== nil) + else if (_filterPredicate != nil) ... // Implies _filterPredicate && ![_filterPredicate evaluateWithObject:object], so the new object does // not appear in arrangedObjects and we do not have to update at all. @@ -867,7 +867,7 @@ _disableSetContent = NO; - if (_filterPredicate === nil || [_filterPredicate evaluateWithObject:object]) + if (_filterPredicate == nil || [_filterPredicate evaluateWithObject:object]) { // selectionIndexes change notification will be fired as a result of the // content change. Don't fire manually. diff --git a/AppKit/CPButton.j b/AppKit/CPButton.j index 010452048..2ed379944 100644 --- a/AppKit/CPButton.j +++ b/AppKit/CPButton.j @@ -807,7 +807,7 @@ CPButtonImageOffset = 3.0; { var selfWindow = [self window]; - if (selfWindow === aWindow || aWindow === nil) + if (selfWindow === aWindow || aWindow == nil) return; if ([selfWindow defaultButton] === self) diff --git a/AppKit/CPCollectionView.j b/AppKit/CPCollectionView.j index b85dfcb0d..9c6a7f508 100644 --- a/AppKit/CPCollectionView.j +++ b/AppKit/CPCollectionView.j @@ -739,7 +739,7 @@ var HORIZONTAL_MARGIN = 2; */ - (void)setMinItemSize:(CGSize)aSize { - if (aSize === nil || aSize === undefined) + if (aSize == nil) [CPException raise:CPInvalidArgumentException reason:"Invalid value provided for minimum size"]; if (CGSizeEqualToSize(_minItemSize, aSize)) diff --git a/AppKit/CPComboBox.j b/AppKit/CPComboBox.j index 61a159ed7..a825651b3 100644 --- a/AppKit/CPComboBox.j +++ b/AppKit/CPComboBox.j @@ -564,7 +564,7 @@ var CPComboBoxTextSubview = @"text", var selectedStringValue = [_listDelegate selectedStringValue]; - if (selectedStringValue === nil) + if (selectedStringValue == nil) return NO; else _selectedStringValue = selectedStringValue; diff --git a/AppKit/CPControl.j b/AppKit/CPControl.j index e2284cb96..c8fcb0680 100644 --- a/AppKit/CPControl.j +++ b/AppKit/CPControl.j @@ -622,15 +622,15 @@ var CPControlBlackColor = [CPColor blackColor]; */ - (CPString)stringValue { - if (_formatter && _value !== undefined) + if (_formatter && _value != nil) { var formattedValue = [self hasThemeState:CPThemeStateEditing] ? [_formatter editingStringForObjectValue:_value] : [_formatter stringForObjectValue:_value]; - if (formattedValue !== nil && formattedValue !== undefined) + if (formattedValue != nil) return formattedValue; } - return (_value === undefined || _value === nil) ? @"" : String(_value); + return _value == nil ? @"" : String(_value); } /*! @@ -639,7 +639,7 @@ var CPControlBlackColor = [CPColor blackColor]; - (void)setStringValue:(CPString)aString { // Cocoa raises an invalid parameter assertion and returns if you pass nil. - if (aString === nil || aString === undefined) + if (aString == nil) { CPLog.warn("nil or undefined sent to CPControl -setStringValue"); return; @@ -1137,18 +1137,18 @@ var CPControlActionKey = @"CPControlActionKey", var objectValue = [self objectValue]; - if (objectValue !== nil) + if (objectValue != nil) [aCoder encodeObject:objectValue forKey:CPControlValueKey]; - if (_target !== nil) + if (_target != nil) [aCoder encodeConditionalObject:_target forKey:CPControlTargetKey]; - if (_action !== nil) + if (_action != nil) [aCoder encodeObject:_action forKey:CPControlActionKey]; [aCoder encodeInt:_sendActionOn forKey:CPControlSendActionOnKey]; - if (_formatter !== nil) + if (_formatter != nil) [aCoder encodeObject:_formatter forKey:CPControlFormatterKey]; [aCoder encodeInt:_controlSize forKey:CPControlControlSizeKey]; diff --git a/AppKit/CPDictionaryController.j b/AppKit/CPDictionaryController.j index da885d40b..1feeadc18 100644 --- a/AppKit/CPDictionaryController.j +++ b/AppKit/CPDictionaryController.j @@ -69,7 +69,7 @@ aNewObject._controller = self; aNewObject._key = aKey; - if (aValue !== nil) + if (aValue != nil) [aNewObject setValue:aValue]; return aNewObject; @@ -98,7 +98,7 @@ var iter = [[CPSet setWithArray:allKeys] objectEnumerator], obj; - while ((obj = [iter nextObject]) !== nil) + while ((obj = [iter nextObject]) != nil) if (![_excludedKeys containsObject:obj]) [array addObject:[self _newObjectWithKey:obj value:nil]]; diff --git a/AppKit/CPDocumentController.j b/AppKit/CPDocumentController.j index 139f34d6b..4029443e4 100644 --- a/AppKit/CPDocumentController.j +++ b/AppKit/CPDocumentController.j @@ -297,7 +297,7 @@ var CPSharedDocumentController = nil; var iter = [_documents objectEnumerator], obj; - while ((obj = [iter nextObject]) !== nil) + while ((obj = [iter nextObject]) != nil) { if ([obj isDocumentEdited]) return YES; diff --git a/AppKit/CPEvent.j b/AppKit/CPEvent.j index a6e99f265..7bc06d501 100644 --- a/AppKit/CPEvent.j +++ b/AppKit/CPEvent.j @@ -608,7 +608,7 @@ var _CPEventPeriodicEventPeriod = 0, */ + (void)stopPeriodicEvents { - if (_CPEventPeriodicEventTimer === nil) + if (_CPEventPeriodicEventTimer == nil) return; window.clearTimeout(_CPEventPeriodicEventTimer); diff --git a/AppKit/CPFlashView.j b/AppKit/CPFlashView.j index 76f0b0193..d69b06276 100644 --- a/AppKit/CPFlashView.j +++ b/AppKit/CPFlashView.j @@ -145,7 +145,7 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; var enumerator = [_params keyEnumerator], key; - while (_DOMObjectElement && (key = [enumerator nextObject]) !== nil) + while (_DOMObjectElement && (key = [enumerator nextObject]) != nil) { var param = document.createElement(@"param"); param.name = key; @@ -177,7 +177,7 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; paramEnumerator = [_params keyEnumerator], key; - while ((key = [paramEnumerator nextObject]) !== nil) + while ((key = [paramEnumerator nextObject]) != nil) paramString = [paramString stringByAppendingFormat:@"", key, [_params objectForKey:key]]; _DOMObjectElement = document.createElement(@"object"); diff --git a/AppKit/CPFontManager.j b/AppKit/CPFontManager.j index 2cac256df..749dd778c 100644 --- a/AppKit/CPFontManager.j +++ b/AppKit/CPFontManager.j @@ -207,7 +207,7 @@ CPRemoveTraitFontAction = 7; - (@action)addFontTrait:(id)sender { var tag = [sender tag]; - _activeChange = tag === nil ? @{} : @{ @"addTraits": tag }; + _activeChange = tag == nil ? @{} : @{ @"addTraits": tag }; _fontAction = CPAddTraitFontAction; [self sendAction]; diff --git a/AppKit/CPImage.j b/AppKit/CPImage.j index 1df9d2fa7..060f6d71c 100644 --- a/AppKit/CPImage.j +++ b/AppKit/CPImage.j @@ -85,7 +85,7 @@ function CPImageInBundle() if (typeof(arguments[1]) === "number") { - if (arguments[1] !== nil && arguments[1] !== undefined) + if (arguments[1] != nil) size = CGSizeMake(arguments[1], arguments[2]); bundle = arguments[3]; @@ -161,7 +161,7 @@ function CPAppKitImage(aFilename, aSize) - (id)initByReferencingFile:(CPString)aFilename size:(CGSize)aSize { // Quietly return nil like in Cocoa, rather than crashing later. - if (aFilename === undefined || aFilename === nil) + if (aFilename == nil) return nil; self = [super init]; diff --git a/AppKit/CPKeyValueBinding.j b/AppKit/CPKeyValueBinding.j index 05a9fd585..838f1091e 100644 --- a/AppKit/CPKeyValueBinding.j +++ b/AppKit/CPKeyValueBinding.j @@ -293,7 +293,7 @@ var CPBindingOperationAnd = 0, // If the value is nil AND the source doesn't respond to setPlaceholderString: then // we set the value to the placeholder. Otherwise, we do not want to short cut the process // of setting the placeholder that is based on the fact that the value is nil. - if ((aValue === undefined || aValue === nil || aValue === [CPNull null]) + if ((aValue == nil || aValue === [CPNull null]) && ![_source respondsToSelector:@selector(setPlaceholderString:)]) aValue = [options objectForKey:CPNullPlaceholderBindingOption] || nil; @@ -653,7 +653,7 @@ var CPBindingOperationAnd = 0, keyPath = [info objectForKey:CPObservedKeyPathKey], value = [object valueForKeyPath:keyPath]; - if (value === nil || value === undefined) + if (value == nil) { [_source setEnabled:NO]; return; @@ -796,7 +796,7 @@ var CPBindingOperationAnd = 0, else value = [theBinding transformValue:value withOptions:options]; - if (value === nil || value === undefined) + if (value == nil) value = @""; result.value = result.value.replace("%{" + _patternPlaceholder + count + "}@", [value description]); diff --git a/AppKit/CPMenu/CPMenu.j b/AppKit/CPMenu/CPMenu.j index a3c96dc43..655022c97 100644 --- a/AppKit/CPMenu/CPMenu.j +++ b/AppKit/CPMenu/CPMenu.j @@ -164,7 +164,7 @@ var _CPMenuBarVisible = NO, + (void)_setOrRemoveMenuBarAttribute:(id)aValue forKey:(id)aKey { - if (aValue === nil) + if (aValue == nil) [_CPMenuBarAttributes removeObjectForKey:aKey]; else [_CPMenuBarAttributes setObject:aValue forKey:aKey]; diff --git a/AppKit/CPMenu/_CPMenuManager.j b/AppKit/CPMenu/_CPMenuManager.j index 4712a7e7e..8ad054f34 100644 --- a/AppKit/CPMenu/_CPMenuManager.j +++ b/AppKit/CPMenu/_CPMenuManager.j @@ -553,7 +553,7 @@ var STICKY_TIME_INTERVAL = 0.4, var iter = [selectorNames objectEnumerator], obj; - while ((obj = [iter nextObject]) !== nil) + while ((obj = [iter nextObject]) != nil) { var aSelector = CPSelectorFromString(obj); @@ -587,7 +587,7 @@ var STICKY_TIME_INTERVAL = 0.4, var iter = [[menu itemArray] objectEnumerator], obj; - while ((obj = [iter nextObject]) !== nil) + while ((obj = [iter nextObject]) != nil) { if ([obj isHidden] || ![obj isEnabled]) continue; diff --git a/AppKit/CPObjectController.j b/AppKit/CPObjectController.j index 6bd5102db..479d3a4e1 100644 --- a/AppKit/CPObjectController.j +++ b/AppKit/CPObjectController.j @@ -384,7 +384,7 @@ */ - (void)_selectionDidChange { - if (_selection === undefined || _selection === nil) + if (_selection == nil) _selection = [[CPControllerSelectionProxy alloc] initWithController:self]; [_selection controllerDidChange]; @@ -770,7 +770,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo } } - if (value === nil || value.isa && [value isEqual:[CPNull null]]) + if (value == nil || value.isa && [value isEqual:[CPNull null]]) value = CPNullMarker; return value; diff --git a/AppKit/CPOutlineView.j b/AppKit/CPOutlineView.j index e3533799f..a45be4e43 100644 --- a/AppKit/CPOutlineView.j +++ b/AppKit/CPOutlineView.j @@ -1438,7 +1438,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0, _shouldRetargetChildIndex = YES; // set CPTableView's _retargetedDropRow based on retargetedItem and retargetedChildIndex - var retargetedItemInfo = (_retargetedItem !== nil) ? _itemInfosForItems[[_retargetedItem UID]] : _rootItemInfo; + var retargetedItemInfo = (_retargetedItem != nil) ? _itemInfosForItems[[_retargetedItem UID]] : _rootItemInfo; if (_retargedChildIndex === [retargetedItemInfo.children count]) { @@ -1940,7 +1940,7 @@ var CPOutlineViewCoalesceSelectionNotificationStateOff = 0, if (theDropOperation === CPTableViewDropAbove) { var parentItem = [_outlineView _parentItemForUpperRow:theRow - 1 andLowerRow:theRow atMouseOffset:theOffset], - itemInfo = (parentItem !== nil) ? _outlineView._itemInfosForItems[[parentItem UID]] : _outlineView._rootItemInfo, + itemInfo = (parentItem != nil) ? _outlineView._itemInfosForItems[[parentItem UID]] : _outlineView._rootItemInfo, children = itemInfo.children; childIndex = [children indexOfObject:[_outlineView itemAtRow:theRow]]; diff --git a/AppKit/CPResponder.j b/AppKit/CPResponder.j index eb1bc841c..0b7467dd7 100644 --- a/AppKit/CPResponder.j +++ b/AppKit/CPResponder.j @@ -397,7 +397,7 @@ var CPResponderNextResponderKey = @"CPResponderNextResponderKey", - (void)encodeWithCoder:(CPCoder)aCoder { // This will come out nil on the other side with decodeObjectForKey: - if (_nextResponder !== nil) + if (_nextResponder != nil) [aCoder encodeConditionalObject:_nextResponder forKey:CPResponderNextResponderKey]; [aCoder encodeObject:_menu forKey:CPResponderMenuKey]; diff --git a/AppKit/CPRuleEditor/CPRuleEditor.j b/AppKit/CPRuleEditor/CPRuleEditor.j index ac3bcd52c..f3b3e0726 100644 --- a/AppKit/CPRuleEditor/CPRuleEditor.j +++ b/AppKit/CPRuleEditor/CPRuleEditor.j @@ -157,7 +157,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType", - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; - if (self !== nil) + if (self) { _slices = [[CPMutableArray alloc] init]; @@ -419,7 +419,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType", */ - (void)setFormattingStringsFilename:(CPString)stringsFilename { - if (_standardLocalizer === nil) + if (_standardLocalizer == nil) _standardLocalizer = [_CPRuleEditorLocalizer new]; if (_stringsFilename !== stringsFilename) @@ -427,14 +427,14 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType", // Convert an empty string to nil _stringsFilename = stringsFilename || nil; - if (stringsFilename !== nil) + if (stringsFilename != nil) { if (![stringsFilename hasSuffix:@".strings"]) stringsFilename = stringsFilename + @".strings"; var path = [[CPBundle mainBundle] pathForResource:stringsFilename]; - if (path !== nil) + if (path != nil) [_standardLocalizer loadContentOfURL:[CPURL URLWithString:path]]; } } @@ -465,7 +465,7 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType", */ - (void)setCriteria:(CPArray)criteria andDisplayValues:(CPArray)values forRowAtIndex:(int)rowIndex { - if (criteria === nil || values === nil) + if (criteria == nil || values == nil) [CPException raise:CPInvalidArgumentException reason:_cmd + @". criteria and values parameters must not be nil."]; if (rowIndex < 0 || rowIndex >= [self numberOfRows]) @@ -852,7 +852,7 @@ TODO: implement while (current_index !== CPNotFound) { var subpredicate = [self predicateForRow:current_index]; - if (subpredicate !== nil) + if (subpredicate != nil) [subpredicates addObject:subpredicate]; current_index = [subrowsIndexes indexGreaterThanIndex:current_index]; @@ -888,33 +888,33 @@ TODO: implement modifier = [predicateParts objectForKey:CPRuleEditorPredicateComparisonModifier], selector = CPSelectorFromString([predicateParts objectForKey:CPRuleEditorPredicateCustomSelector]); - if (lhs === nil) + if (lhs == nil) { CPLogConsole(@"missing left expression in predicate parts dictionary"); return NULL; } - if (rhs === nil) + if (rhs == nil) { CPLogConsole(@"missing right expression in predicate parts dictionary"); return NULL; } - if (selector === nil && operator === nil) + if (selector == nil && operator == nil) { CPLogConsole(@"missing operator and selector in predicate parts dictionary"); return NULL; } - if (modifier === nil) + if (modifier == nil) CPLogConsole(@"missing modifier in predicate parts dictionary. Setting default: CPDirectPredicateModifier"); - if (options === nil) + if (options == nil) CPLogConsole(@"missing options in predicate parts dictionary. Setting default: CPCaseInsensitivePredicateOption"); try { - if (selector !== nil) + if (selector != nil) predicate = [CPComparisonPredicate predicateWithLeftExpression:lhs rightExpression:rhs customSelector:selector @@ -1167,7 +1167,7 @@ TODO: implement - (BOOL)_wantsRowAnimations { - return (_currentAnimation !== nil); + return (_currentAnimation != nil); } - (void)_updateButtonVisibilities @@ -1753,7 +1753,7 @@ TODO: implement { var subpredicate = [self predicateForRow:current_index]; - if (subpredicate !== nil) + if (subpredicate != nil) [subpredicates addObject:subpredicate]; current_index = [subindexes indexGreaterThanIndex:current_index]; @@ -1795,7 +1795,7 @@ TODO: implement startRect = [aslice frame], startIndex = [aslice rowIndex] - 1; - if ([aslice superview] === nil) + if ([aslice superview] == nil) { startRect = CGRectMake(0, startIndex * _sliceHeight, CGRectGetWidth(startRect), _sliceHeight); [aslice _reconfigureSubviews]; @@ -2129,7 +2129,7 @@ TODO: implement - (BOOL)_dragShouldBeginFromMouseDown:(CPView)view { - return (([self nestingMode] === CPRuleEditorNestingModeList || [view rowIndex] !== 0) && _editable && [view isKindOfClass:[_CPRuleEditorViewSliceRow class]] && _draggingRows === nil); + return (([self nestingMode] === CPRuleEditorNestingModeList || [view rowIndex] !== 0) && _editable && [view isKindOfClass:[_CPRuleEditorViewSliceRow class]] && _draggingRows == nil); } - (BOOL)_performDragForSlice:(id)slice withEvent:(CPEvent)event @@ -2321,7 +2321,7 @@ TODO: implement - (void)_postRowCountChangedNotificationOfType:(CPString)notificationName indexes:indexes { - var userInfo = indexes === nil ? @{} : @{ "indexes": indexes }; + var userInfo = indexes == nil ? @{} : @{ "indexes": indexes }; [[CPNotificationCenter defaultCenter] postNotificationName:notificationName object:self userInfo:userInfo]; } @@ -2386,7 +2386,7 @@ TODO: implement var criteria = [self criteriaForRow:aRow]; indexofCriterion = [criteria indexOfObject:criterion]; - if (parentItem !== nil + if (parentItem != nil && indexofCriterion !== CPNotFound && indexofCriterion < [criteria count] - 1) { @@ -2469,7 +2469,7 @@ var CPRuleEditorAlignmentGridWidthKey = @"CPRuleEditorAlignmentGridWidth", - (id)initWithCoder:(CPCoder)coder { self = [super initWithCoder:coder]; - if (self !== nil) + if (self) { [self setFormattingStringsFilename:[coder decodeObjectForKey:CPRuleEditorStringsFilenameKey]]; _alignmentGridWidth = [coder decodeFloatForKey:CPRuleEditorAlignmentGridWidthKey]; @@ -2553,7 +2553,7 @@ var CriteriaKey = @"criteria", - (id)initWithCoder:(CPCoder)coder { self = [super init]; - if (self !== nil) + if (self) { subrows = [coder decodeObjectForKey:SubrowsKey]; criteria = [coder decodeObjectForKey:CriteriaKey]; diff --git a/AppKit/CPRuleEditor/_CPPredicateEditorRowNode.j b/AppKit/CPRuleEditor/_CPPredicateEditorRowNode.j index ed9b59f0f..020caf528 100644 --- a/AppKit/CPRuleEditor/_CPPredicateEditorRowNode.j +++ b/AppKit/CPRuleEditor/_CPPredicateEditorRowNode.j @@ -131,7 +131,7 @@ { var title = [self title]; - if (title !== nil) + if (title != nil) return title; return [self templateView]; diff --git a/AppKit/CPRuleEditor/_CPRuleEditorLocalizer.j b/AppKit/CPRuleEditor/_CPRuleEditorLocalizer.j index a9c5d7da9..12bbbe514 100644 --- a/AppKit/CPRuleEditor/_CPRuleEditorLocalizer.j +++ b/AppKit/CPRuleEditor/_CPRuleEditorLocalizer.j @@ -40,7 +40,7 @@ var LocalizerStringsRegex = new RegExp("\"(.+)\"\\s*=\\s*\"(.+)\"\\s*;\\s*(//.+) - (void)reloadIfNeeded { - if (connection !== nil) // Connection waiting + if (connection != nil) // Connection waiting { connection = nil; @@ -51,7 +51,7 @@ var LocalizerStringsRegex = new RegExp("\"(.+)\"\\s*=\\s*\"(.+)\"\\s*;\\s*(//.+) - (void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)rawString { - if (connection !== nil && rawString !== nil) + if (connection != nil && rawString != nil) [self loadContent:rawString]; connection = nil; @@ -83,11 +83,11 @@ var LocalizerStringsRegex = new RegExp("\"(.+)\"\\s*=\\s*\"(.+)\"\\s*;\\s*(//.+) { [self reloadIfNeeded]; - if (_dictionary !== nil && aString !== nil) + if (_dictionary != nil && aString != nil) { var localized = [_dictionary objectForKey:aString]; - if (localized !== nil) + if (localized != nil) return localized; } diff --git a/AppKit/CPScrollView.j b/AppKit/CPScrollView.j index 9f2009a32..2b42f709c 100644 --- a/AppKit/CPScrollView.j +++ b/AppKit/CPScrollView.j @@ -147,7 +147,7 @@ var CPScrollerStyleGlobal = CPScrollerStyleOverlay, var globalValue = [[CPBundle mainBundle] objectForInfoDictionaryKey:@"CPScrollersGlobalStyle"]; - if (globalValue === nil || globalValue === -1) + if (globalValue == nil || globalValue === -1) CPScrollerStyleGlobal = _isBrowserUsingOverlayScrollers() ? CPScrollerStyleOverlay : CPScrollerStyleLegacy else CPScrollerStyleGlobal = globalValue; @@ -309,7 +309,7 @@ Notifies the delegate when the scroll view has finished scrolling. _delegate = aDelegate; _implementedDelegateMethods = 0; - if (_delegate === nil) + if (_delegate == nil) return; if ([_delegate respondsToSelector:@selector(scrollViewWillScroll:)]) diff --git a/AppKit/CPSearchField.j b/AppKit/CPSearchField.j index eeb852a75..1ceba1d34 100644 --- a/AppKit/CPSearchField.j +++ b/AppKit/CPSearchField.j @@ -183,7 +183,7 @@ var CPAutosavedRecentsChangedNotification = @"CPAutosavedRecentsChangedNotificat - (void)resetSearchButton { var button = [self searchButton], - searchButtonImage = (_searchMenuTemplate === nil) ? [self currentValueForThemeAttribute:@"image-search"] : [self currentValueForThemeAttribute:@"image-find"]; + searchButtonImage = (_searchMenuTemplate == nil) ? [self currentValueForThemeAttribute:@"image-search"] : [self currentValueForThemeAttribute:@"image-find"]; [button setBordered:NO]; [button setImageScaling:CPImageScaleAxesIndependently]; @@ -491,7 +491,7 @@ var CPAutosavedRecentsChangedNotification = @"CPAutosavedRecentsChangedNotificat - (void)_addStringToRecentSearches:(CPString)string { - if (string === nil || string === @"" || [_recentSearches containsObject:string]) + if (string == nil || string === @"" || [_recentSearches containsObject:string]) return; var searches = [CPMutableArray arrayWithArray:_recentSearches]; @@ -598,7 +598,7 @@ var CPAutosavedRecentsChangedNotification = @"CPAutosavedRecentsChangedNotificat - (void)_updateSearchMenu { - if (_searchMenuTemplate === nil) + if (_searchMenuTemplate == nil) return; var menu = [[CPMenu alloc] init], @@ -678,7 +678,7 @@ var CPAutosavedRecentsChangedNotification = @"CPAutosavedRecentsChangedNotificat - (void)_showMenu { - if (_searchMenu === nil || [_searchMenu numberOfItems] === 0 || ![self isEnabled]) + if (_searchMenu == nil || [_searchMenu numberOfItems] === 0 || ![self isEnabled]) return; var aFrame = [[self superview] convertRect:[self frame] toView:nil], @@ -752,12 +752,12 @@ var CPAutosavedRecentsChangedNotification = @"CPAutosavedRecentsChangedNotificat - (void)_loadRecentSearchList { var name = [self recentsAutosaveName]; - if (name === nil) + if (name == nil) return; var list = [[CPUserDefaults standardUserDefaults] objectForKey:name]; - if (list !== nil) + if (list != nil) _recentSearches = list; } diff --git a/AppKit/CPSplitView.j b/AppKit/CPSplitView.j index 78c51553c..fa6aaa427 100644 --- a/AppKit/CPSplitView.j +++ b/AppKit/CPSplitView.j @@ -1168,7 +1168,7 @@ The sum of the views and the sum of the dividers should be equal to the size of { var item = preCollapseArray[i]; - if (item === nil) + if (item == nil) [_preCollapsePositions removeObjectForKey:String(i)]; else [_preCollapsePositions setObject:item forKey:String(i)]; diff --git a/AppKit/CPTabView.j b/AppKit/CPTabView.j index f48fb24e7..06c60b452 100644 --- a/AppKit/CPTabView.j +++ b/AppKit/CPTabView.j @@ -275,7 +275,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 1, */ - (void)selectNextTabViewItem:(id)aSender { - if (_selectedTabViewItem === nil) + if (_selectedTabViewItem == nil) return; var nextIndex = [self indexOfTabViewItem:_selectedTabViewItem] + 1; @@ -293,7 +293,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 1, */ - (void)selectPreviousTabViewItem:(id)aSender { - if (_selectedTabViewItem === nil) + if (_selectedTabViewItem == nil) return; var previousIndex = [self indexOfTabViewItem:_selectedTabViewItem] - 1; @@ -353,15 +353,15 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 1, { var controller = [aTabViewItem viewController]; - if (controller !== nil && ![controller isViewLoaded]) + if (controller != nil && ![controller isViewLoaded]) { [controller loadViewWithCompletionHandler:function(view, error) { - if (error !== nil) + if (error != nil) { CPLog.warn("Could not load the view for item " + aTabViewItem + ". " + error); } - else if (view !== nil) + else if (view != nil) { [aTabViewItem setView:view]; @@ -599,7 +599,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1 << 1, { var theBinder = [self binderForBinding:CPSelectionIndexesBinding]; - if (theBinder !== nil) + if (theBinder != nil) [theBinder reverseSetValueFor:@"selectionIndexes"]; else { diff --git a/AppKit/CPTableColumn.j b/AppKit/CPTableColumn.j index e02c5607b..dd1a3c173 100644 --- a/AppKit/CPTableColumn.j +++ b/AppKit/CPTableColumn.j @@ -593,7 +593,7 @@ CPTableColumnUserResizingMask = 1 << 1; { var options = [_info objectForKey:CPOptionsKey], optionValue = [options objectForKey:CPCreatesSortDescriptorBindingOption]; - return optionValue === nil ? YES : [optionValue boolValue]; + return optionValue == nil ? YES : [optionValue boolValue]; } @end diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index a4ec8284d..fcef50846 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -2977,7 +2977,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad oldMainSortDescriptor = [[self sortDescriptors] objectAtIndex: 0]; // Remove every main descriptor equivalents (normally only one) - while ((descriptor = [e nextObject]) !== nil) + while ((descriptor = [e nextObject]) != nil) { if ([[descriptor key] isEqual: [newMainSortDescriptor key]]) [outdatedDescriptors addObject:descriptor]; @@ -3319,7 +3319,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad var oldSortDescriptors = [[self sortDescriptors] copy], newSortDescriptors = [CPArray array]; - if (sortDescriptors !== nil) + if (sortDescriptors != nil) [newSortDescriptors addObjectsFromArray:sortDescriptors]; if ([newSortDescriptors isEqual:oldSortDescriptors]) @@ -3380,7 +3380,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad objectValue = tableColumnObjectValues[aRowIndex]; // tableView:objectValueForTableColumn:row: is optional if content bindings are in place. - if (objectValue === undefined) + if (objectValue == nil) { if ([self _dataSourceRespondsToObjectValueForTableColumn]) { @@ -3835,7 +3835,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad else if ([self _delegateRespondsToDataViewForTableColumn]) _viewForTableColumnRowSelector = @selector(_sendDelegateDataViewForTableColumn:row:); - _isViewBased = (_viewForTableColumnRowSelector !== nil || _archivedDataViews !== nil); + _isViewBased = (_viewForTableColumnRowSelector != nil || _archivedDataViews != nil); } /*! @@ -4724,7 +4724,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad dropOperation = [self _proposedDropOperationAtPoint:location], row = [self _proposedRowAtPoint:location]; - if (_retargetedDropRow !== nil) + if (_retargetedDropRow != nil) row = _retargetedDropRow; var draggedTypes = [self registeredDraggedTypes], @@ -4780,7 +4780,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad */ - (CPTableViewDropOperation)_proposedDropOperationAtPoint:(CGPoint)theDragPoint { - if (_retargetedDropOperation !== nil) + if (_retargetedDropOperation != nil) return _retargetedDropOperation; var row = [self _proposedRowAtPoint:theDragPoint], @@ -4859,10 +4859,10 @@ Your delegate can implement this method to avoid subclassing the tableview to ad row = [self _proposedRowAtPoint:location], dragOperation = [self _sendDataSourceValidateDrop:sender proposedRow:row proposedDropOperation:dropOperation]; - if (_retargetedDropRow !== nil) + if (_retargetedDropRow != nil) row = _retargetedDropRow; - if (_retargetedDropOperation !== nil) + if (_retargetedDropOperation != nil) dropOperation = _retargetedDropOperation; if (dropOperation === CPTableViewDropOn && row >= numberOfRows) @@ -4907,7 +4907,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad operation = [self _proposedDropOperationAtPoint:location], row = _retargetedDropRow; - if (row === nil) + if (row == nil) row = [self _proposedRowAtPoint:location]; return [self _sendDataSourceAcceptDrop:sender row:row dropOperation:operation]; diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 166eee399..23caae450 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -1332,7 +1332,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); // If there is a formatter, make sure the object value can be formatted successfully var formattedString = [self hasThemeState:CPThemeStateEditing] ? [formatter editingStringForObjectValue:aValue] : [formatter stringForObjectValue:aValue]; - if (formattedString === nil) + if (formattedString == nil) { var value = nil; @@ -1342,7 +1342,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); value = undefined; [super setObjectValue:value]; - _stringValue = (value === nil || value === undefined) ? @"" : String(value); + _stringValue = (value == nil) ? @"" : String(value); } else _stringValue = formattedString; @@ -1498,7 +1498,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); else [[CPRunLoop mainRunLoop] performBlock:function(){ element.select(); } argument:nil order:0 modes:[CPDefaultRunLoopMode]]; } - else if (wind !== nil && [wind makeFirstResponder:self]) + else if (wind != nil && [wind makeFirstResponder:self]) [self _selectText:sender immediately:immediately]; } else @@ -1508,7 +1508,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); #else // Even if we can't actually select the text we need to preserve the first // responder side effect. - if (wind !== nil && [wind firstResponder] !== self) + if (wind != nil && [wind firstResponder] !== self) [wind makeFirstResponder:self]; #endif } @@ -2153,7 +2153,7 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey", newValue = [self valueForBinding:aBinding], value = [destination valueForKeyPath:keyPath]; - if (CPIsControllerMarker(value) && newValue === nil) + if (CPIsControllerMarker(value) && newValue == nil) return; newValue = [self reverseTransformValue:newValue withOptions:options]; diff --git a/AppKit/CPTextView/CPFontPanel.j b/AppKit/CPTextView/CPFontPanel.j index 9f19a47af..b3abeece7 100644 --- a/AppKit/CPTextView/CPFontPanel.j +++ b/AppKit/CPTextView/CPFontPanel.j @@ -94,7 +94,7 @@ var _availableTraits= [@"Normal", @"Italic", @"Bold", @"Bold Italic"], */ + (BOOL)sharedFontPanelExists { - return _sharedFontPanel !== nil; + return _sharedFontPanel != nil; } /*! diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index dde39feff..118630bd3 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -980,7 +980,7 @@ Sets the selection to a range of characters in response to user action. if (!isNewSelection && _mouseDownOldSelection) isNewSelection = !CPEqualRanges(newSelectionRange, _mouseDownOldSelection); - if (doOverwrite && _placeholderString === nil && isNewSelection) + if (doOverwrite && _placeholderString == nil && isNewSelection) [self setTypingAttributes:[_textStorage attributesAtIndex:CPMaxRange(range) effectiveRange:nil]]; [[CPNotificationCenter defaultCenter] postNotificationName:CPTextViewDidChangeSelectionNotification object:self]; @@ -2916,7 +2916,7 @@ var _CPCopyPlaceholder = '-'; - (void)setValue:(id)aValue forBinding:(CPString)aBinding { - if (aValue === nil || (aValue.isa && [aValue isMemberOfClass:CPNull])) + if (aValue == nil || (aValue.isa && [aValue isMemberOfClass:CPNull])) [_source _setPlaceholderString:[self _placeholderForMarker:CPNullMarker]]; else [_source _setPlaceholderString:nil]; diff --git a/AppKit/CPTextView/_CPRTFProducer.j b/AppKit/CPTextView/_CPRTFProducer.j index 71b1a32c1..7333b2c55 100644 --- a/AppKit/CPTextView/_CPRTFProducer.j +++ b/AppKit/CPTextView/_CPRTFProducer.j @@ -113,7 +113,7 @@ function _points2twips(a) { return (a) * 20.0; } keyArray = [keyArray sortedArrayUsingSelector:@selector(compare:)]; fontEnum = [keyArray objectEnumerator]; - while ((currFont = [fontEnum nextObject]) !== nil) + while ((currFont = [fontEnum nextObject]) != nil) { var fontFamily, detail; @@ -149,7 +149,7 @@ function _points2twips(a) { return (a) * 20.0; } next, i; - while ((next = [keyEnum nextObject]) !== nil) + while ((next = [keyEnum nextObject]) != nil) { var cn = [colorDict objectForKey:next]; [list insertObject:[CPColor colorWithCSSString:next] atIndex:[cn intValue]-1]; diff --git a/AppKit/CPTheme.j b/AppKit/CPTheme.j index c35e8d399..9da721b7b 100644 --- a/AppKit/CPTheme.j +++ b/AppKit/CPTheme.j @@ -259,7 +259,7 @@ var CPThemesByName = { }, attributeNames = [attributes keyEnumerator], objectThemeClass = [anObject themeClass]; - while ((attributeName = [attributeNames nextObject]) !== nil) + while ((attributeName = [attributeNames nextObject]) != nil) [self _recordAttribute:[attributes objectForKey:attributeName] forClass:objectThemeClass]; } @@ -687,7 +687,7 @@ CPThemeStateNormalString = String(CPThemeStateNormal); { var attribute = [[_CPThemeAttribute alloc] initWithName:_name defaultValue:_defaultValue defaultAttribute:_themeDefaultAttribute]; - if (aValue !== undefined && aValue !== nil) + if (aValue != nil) attribute._values = @{ CPThemeStateNormalString: aValue }; return attribute; @@ -695,7 +695,7 @@ CPThemeStateNormalString = String(CPThemeStateNormal); - (_CPThemeAttribute)attributeBySettingValue:(id)aValue forState:(ThemeState)aState { - var shouldRemoveValue = aValue === undefined || aValue === nil, + var shouldRemoveValue = aValue == nil, attribute = [[_CPThemeAttribute alloc] initWithName:_name defaultValue:_defaultValue defaultAttribute:_themeDefaultAttribute], values = _values; @@ -738,7 +738,7 @@ CPThemeStateNormalString = String(CPThemeStateNormal); // Not in cache. OK, search in values. value = [_values objectForKey:stateName]; - if ((value !== undefined) && (value !== nil)) + if (value != nil) return _cache[stateName] = value; // No direct match in values. @@ -754,13 +754,13 @@ CPThemeStateNormalString = String(CPThemeStateNormal); // Still don't have a value? OK, let's use the normal value. value = [_values objectForKey:String(CPThemeStateNormal)]; - if ((value !== undefined) && (value !== nil)) + if (value != nil) return _cache[stateName] = value; // No normal value, try asking _themeDefaultAttribute value = [_themeDefaultAttribute valueForState:aState]; - if ((value !== undefined) && (value !== nil)) + if (value != nil) return _cache[stateName] = value; // Well, last option, use default value diff --git a/AppKit/CPTokenField.j b/AppKit/CPTokenField.j index e43605dc4..de0b19c73 100644 --- a/AppKit/CPTokenField.j +++ b/AppKit/CPTokenField.j @@ -630,7 +630,7 @@ CPTokenFieldDeleteButtonType = 1; - (void)setObjectValue:(id)aValue { - if (aValue !== nil && ![aValue isKindOfClass:[CPArray class]]) + if (aValue != nil && ![aValue isKindOfClass:[CPArray class]]) { [super setObjectValue:nil]; return; @@ -645,7 +645,7 @@ CPTokenFieldDeleteButtonType = 1; newTokens = []; // Preserve as many existing tokens as possible to reduce redraw flickering. - if (aValue !== nil) + if (aValue != nil) { for (var i = 0, count = [aValue count]; i < count; i++) { @@ -666,7 +666,7 @@ CPTokenFieldDeleteButtonType = 1; } } - if (newToken === nil) + if (newToken == nil) { newToken = [_CPTokenFieldToken new]; [newToken setTokenField:self]; @@ -1310,7 +1310,7 @@ CPTokenFieldDeleteButtonType = 1; { var stringForRepresentedObject = [_tokenFieldDelegate tokenField:self displayStringForRepresentedObject:representedObject]; - if (stringForRepresentedObject !== nil) + if (stringForRepresentedObject != nil) return stringForRepresentedObject; } @@ -1332,7 +1332,7 @@ CPTokenFieldDeleteButtonType = 1; { var approvedObjects = [_tokenFieldDelegate tokenField:self shouldAddObjects:tokens atIndex:index]; - if (approvedObjects !== nil) + if (approvedObjects != nil) return approvedObjects; } @@ -1354,7 +1354,7 @@ CPTokenFieldDeleteButtonType = 1; { var token = [_tokenFieldDelegate tokenField:self representedObjectForEditingString:aString]; - if (token !== nil && token !== undefined) + if (token != nil) return token; // If nil was returned, assume the string is the represented object. The alternative would have been // to not add anything to the object value array for a nil response. diff --git a/AppKit/CPToolbar.j b/AppKit/CPToolbar.j index 54bece326..bcfec1aee 100644 --- a/AppKit/CPToolbar.j +++ b/AppKit/CPToolbar.j @@ -363,7 +363,7 @@ var CPToolbarsByIdentifier = nil, item = [item copy]; - if (item === nil) + if (item == nil) [CPException raise:CPInvalidArgumentException reason:@"Toolbar delegate " + _delegate + " returned nil toolbar item for identifier \"" + identifier + "\""]; diff --git a/AppKit/CPTrackingArea.j b/AppKit/CPTrackingArea.j index a88d273b0..2412927f5 100644 --- a/AppKit/CPTrackingArea.j +++ b/AppKit/CPTrackingArea.j @@ -51,7 +51,7 @@ CPTrackingOwnerImplementsCursorUpdate = 1 << 4; /*! @ingroup appkit - + A CPTrackingArea defines a region of view that generates mouse-tracking and cursor-update events when the mouse is over that region. */ @@ -61,7 +61,7 @@ CPTrackingOwnerImplementsCursorUpdate = 1 << 4; CPTrackingAreaOptions _options @accessors(getter=options); id _owner @accessors(getter=owner); CPDictionary _userInfo @accessors(getter=userInfo); - + CPView _referencingView @accessors(property=view); CGRect _windowRect @accessors(getter=windowRect); @@ -72,13 +72,13 @@ CPTrackingOwnerImplementsCursorUpdate = 1 << 4; #pragma mark - #pragma mark Initialization -/*! - Initializes and returns an object defining a region of a view to receive mouse-tracking events, mouse-moved events, cursor-update events, or possibly +/*! + Initializes and returns an object defining a region of a view to receive mouse-tracking events, mouse-moved events, cursor-update events, or possibly all these events. */ - (CPTrackingArea)initWithRect:(CGRect)aRect options:(CPTrackingAreaOptions)options owner:(id)owner userInfo:(CPDictionary)userInfo { - if (owner === nil) + if (owner == nil) [CPException raise:CPInternalInconsistencyException reason:"No owner specified"]; if (options === 0) @@ -116,7 +116,7 @@ CPTrackingOwnerImplementsCursorUpdate = 1 << 4; if ([_owner respondsToSelector:@selector(cursorUpdate:)]) _implementedOwnerMethods |= CPTrackingOwnerImplementsCursorUpdate; } - + return self; } @@ -156,7 +156,7 @@ CPTrackingOwnerImplementsCursorUpdate = 1 << 4; _referencingView = [aCoder decodeObjectForKey:CPTrackingAreaReferencingViewKey]; _windowRect = [aCoder decodeObjectForKey:CPTrackingAreaWindowRect]; } - + return self; } diff --git a/AppKit/CPUserDefaultsController.j b/AppKit/CPUserDefaultsController.j index 61eae10d8..102e1dc0a 100644 --- a/AppKit/CPUserDefaultsController.j +++ b/AppKit/CPUserDefaultsController.j @@ -160,13 +160,13 @@ var CPUserDefaultsControllerSharedKey = "CPUserDefaultsControllerSharedKey"; - (id)valueForKey:(CPString)aKey { var value = [_cachedValues objectForKey:aKey]; - if (value === nil) + if (value == nil) { value = [[_controller defaults] objectForKey:aKey]; - if (value === nil) + if (value == nil) value = [[_controller initialValues] objectForKey:aKey]; - if (value !== nil) + if (value != nil) [_cachedValues setObject:value forKey:aKey]; } return value; @@ -220,7 +220,7 @@ var CPUserDefaultsControllerSharedKey = "CPUserDefaultsControllerSharedKey"; [self willChangeValueForKey:key]; var initialValue = [initial objectForKey:key]; - if (initialValue !== nil) + if (initialValue != nil) [_cachedValues setObject:initialValue forKey:key]; else [_cachedValues removeObjectForKey:key]; diff --git a/AppKit/CPView.j b/AppKit/CPView.j index c2cad33ad..277e01e2b 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -800,7 +800,7 @@ var CPViewHighDPIDrawingEnabled = YES; var addedSubview = nil, addedSubviewEnumerator = [addedSubviews objectEnumerator]; - while ((addedSubview = [addedSubviewEnumerator nextObject]) !== nil) + while ((addedSubview = [addedSubviewEnumerator nextObject]) != nil) [self addSubview:addedSubview]; // If the order is fine, no need to reorder. @@ -1703,8 +1703,8 @@ var CPViewHighDPIDrawingEnabled = YES; - (void)_setSuperview:(CPView)aSuperview { - var hasOldSuperview = (_superview !== nil), - hasNewSuperview = (aSuperview !== nil), + var hasOldSuperview = (_superview != nil), + hasNewSuperview = (aSuperview != nil), oldSuperviewIsHidden = hasOldSuperview && [_superview isHiddenOrHasHiddenAncestor], newSuperviewIsHidden = hasNewSuperview && [aSuperview isHiddenOrHasHiddenAncestor]; @@ -3802,7 +3802,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask", // Other views (CPBox) might set an autoresizes mask on their subviews before it is actually decoded. // We make sure we don't override the value by checking if it was already set. - if (_autoresizingMask === nil) + if (_autoresizingMask == nil) _autoresizingMask = [aCoder decodeIntForKey:CPViewAutoresizingMaskKey] || CPViewNotSizable; _autoresizesSubviews = ![aCoder containsValueForKey:CPViewAutoresizesSubviewsKey] || [aCoder decodeBoolForKey:CPViewAutoresizesSubviewsKey]; @@ -3876,7 +3876,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask", [aCoder encodeRect:_bounds forKey:CPViewBoundsKey]; // This will come out nil on the other side with decodeObjectForKey: - if (_window !== nil) + if (_window != nil) [aCoder encodeConditionalObject:_window forKey:CPViewWindowKey]; var count = [_subviews count], @@ -3895,7 +3895,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask", [aCoder encodeObject:encodedSubviews forKey:CPViewSubviewsKey]; // This will come out nil on the other side with decodeObjectForKey: - if (_superview !== nil) + if (_superview != nil) [aCoder encodeConditionalObject:_superview forKey:CPViewSuperviewKey]; if (_autoresizingMask !== CPViewNotSizable) @@ -3904,7 +3904,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask", if (!_autoresizesSubviews) [aCoder encodeBool:_autoresizesSubviews forKey:CPViewAutoresizesSubviewsKey]; - if (_backgroundColor !== nil) + if (_backgroundColor != nil) [aCoder encodeObject:_backgroundColor forKey:CPViewBackgroundColorKey]; if (_hitTests !== YES) @@ -3921,12 +3921,12 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask", var nextKeyView = [self nextKeyView]; - if (nextKeyView !== nil && ![nextKeyView isEqual:self]) + if (nextKeyView != nil && ![nextKeyView isEqual:self]) [aCoder encodeConditionalObject:nextKeyView forKey:CPViewNextKeyViewKey]; var previousKeyView = [self previousKeyView]; - if (previousKeyView !== nil && ![previousKeyView isEqual:self]) + if (previousKeyView != nil && ![previousKeyView isEqual:self]) [aCoder encodeConditionalObject:previousKeyView forKey:CPViewPreviousKeyViewKey]; [self _encodeThemeObjectsWithCoder:aCoder]; diff --git a/AppKit/CPViewController.j b/AppKit/CPViewController.j index 104313474..beb6d4b02 100644 --- a/AppKit/CPViewController.j +++ b/AppKit/CPViewController.j @@ -258,7 +258,7 @@ var CPViewControllerCachedCibs; [self loadView]; - if (_view === nil && [cibOwner isKindOfClass:[CPDocument class]]) + if (_view == nil && [cibOwner isKindOfClass:[CPDocument class]]) [self setView:[cibOwner valueForKey:@"view"]]; if (!_view) @@ -408,7 +408,7 @@ var CPViewControllerCachedCibs; [self willChangeValueForKey:"isViewLoaded"]; _view = aView; - _isViewLoaded = aView !== nil; + _isViewLoaded = aView != nil; if (willChangeIsViewLoaded) [self didChangeValueForKey:"isViewLoaded"]; @@ -421,7 +421,7 @@ var CPViewControllerCachedCibs; - (void)_registerOrUnregister:(BOOL)shouldRegister notificationsForView:(CPView)aView { - if (aView === nil) + if (aView == nil) return; var center = [CPNotificationCenter defaultCenter], diff --git a/AppKit/CPWebView.j b/AppKit/CPWebView.j index a382122d0..aa007756c 100644 --- a/AppKit/CPWebView.j +++ b/AppKit/CPWebView.j @@ -470,7 +470,7 @@ CPWebViewAppKitScrollMaxPollCount = 3; _iframe.src = _url; } - else if (_html !== nil) + else if (_html != nil) { // clear the iframe _iframe.src = ""; @@ -480,7 +480,7 @@ CPWebViewAppKitScrollMaxPollCount = 3; _ignoreLoadEnd = NO; - if (_loadHTMLStringTimer !== nil) + if (_loadHTMLStringTimer != nil) { window.clearTimeout(_loadHTMLStringTimer); _loadHTMLStringTimer = nil; @@ -848,7 +848,7 @@ CPWebViewAppKitScrollMaxPollCount = 3; - (@action)reload:(id)sender { // If we're displaying pure HTML, redisplay it. - if (!_url && (_html !== nil)) + if (!_url && (_html != nil)) [self loadHTMLString:_html]; else [self _loadMainFrameURL]; diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index 34db2982f..acb0028e8 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -3119,7 +3119,7 @@ CPTexturedBackgroundWindowMask */ - (CPWindow)attachedSheet { - if (_sheetContext === nil) + if (_sheetContext == nil) return nil; return _sheetContext["sheet"]; diff --git a/AppKit/CPWindow/_CPWindowView.j b/AppKit/CPWindow/_CPWindowView.j index 50d90b5c4..812b09c7e 100644 --- a/AppKit/CPWindow/_CPWindowView.j +++ b/AppKit/CPWindow/_CPWindowView.j @@ -752,7 +752,7 @@ _CPWindowViewResizeSlop = 3; - (BOOL)showsResizeIndicator { - return _resizeIndicator !== nil; + return _resizeIndicator != nil; } - (void)setResizeIndicatorOffset:(CGSize)anOffset diff --git a/AppKit/CPWindowController.j b/AppKit/CPWindowController.j index 8edc7fc97..f652f1954 100644 --- a/AppKit/CPWindowController.j +++ b/AppKit/CPWindowController.j @@ -168,7 +168,7 @@ */ - (BOOL)isWindowLoaded { - return _window !== nil; + return _window != nil; } /*! @@ -184,7 +184,7 @@ [self loadWindow]; - if (_window === nil && [_cibOwner isKindOfClass:[CPDocument class]]) + if (_window == nil && [_cibOwner isKindOfClass:[CPDocument class]]) [self setWindow:[_cibOwner valueForKey:@"window"]]; if (!_window) diff --git a/AppKit/Cib/CPCib.j b/AppKit/Cib/CPCib.j index d7ac4b500..94fe2dd3d 100644 --- a/AppKit/Cib/CPCib.j +++ b/AppKit/Cib/CPCib.j @@ -152,7 +152,7 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey"; var key = nil, keyEnumerator = [replacementClasses keyEnumerator]; - while ((key = [keyEnumerator nextObject]) !== nil) + while ((key = [keyEnumerator nextObject]) != nil) [unarchiver setClass:[replacementClasses objectForKey:key] forClassName:key]; } diff --git a/AppKit/Cib/_CPCibObjectData.j b/AppKit/Cib/_CPCibObjectData.j index 5cfb03fa6..b240bcaa0 100644 --- a/AppKit/Cib/_CPCibObjectData.j +++ b/AppKit/Cib/_CPCibObjectData.j @@ -110,7 +110,7 @@ var object = nil, objectEnumerator = [_visibleWindows objectEnumerator]; - while ((object = [objectEnumerator nextObject]) !== nil) + while ((object = [objectEnumerator nextObject]) != nil) [_replacementObjects[[object UID]] makeKeyAndOrderFront:self]; } diff --git a/AppKit/CoreAnimation/CPViewAnimator.j b/AppKit/CoreAnimation/CPViewAnimator.j index 0e2db6c59..6b9ef21da 100644 --- a/AppKit/CoreAnimation/CPViewAnimator.j +++ b/AppKit/CoreAnimation/CPViewAnimator.j @@ -260,7 +260,7 @@ var frameToCSSTranslationTransformMatrix = function(start, current) return nil; } - if ([[self animatorClass] _cssPropertiesForKeyPath:aKey] !== nil) + if ([[self animatorClass] _cssPropertiesForKeyPath:aKey] != nil) return [CAAnimation animation]; return nil; diff --git a/AppKit/CoreAnimation/_CPObjectAnimator.j b/AppKit/CoreAnimation/_CPObjectAnimator.j index 192735f42..ebbfa4944 100644 --- a/AppKit/CoreAnimation/_CPObjectAnimator.j +++ b/AppKit/CoreAnimation/_CPObjectAnimator.j @@ -25,7 +25,7 @@ var _supportsCSSAnimations = null; if ([self class] !== [_CPObjectAnimator class]) return; - var compat = (CPBrowserCSSProperty("animation") !== nil); + var compat = (CPBrowserCSSProperty("animation") != nil); CPSetPlatformFeature(CPCSSAnimationFeature, compat); } diff --git a/AppKit/CoreGraphics/CGContext.j b/AppKit/CoreGraphics/CGContext.j index 158169cff..41aba64be 100644 --- a/AppKit/CoreGraphics/CGContext.j +++ b/AppKit/CoreGraphics/CGContext.j @@ -374,7 +374,7 @@ function CGContextFillRect(aContext, aRect) */ function CGContextFillRects(aContext, rects, count) { - if (arguments[2] === undefined) + if (arguments[2] == nil) var count = rects.length; CGContextBeginPath(aContext); @@ -641,7 +641,7 @@ function CGContextStrokeLineSegments(aContext, points, count) { var i = 0; - if (count === NULL) + if (count == NULL) var count = points.length; CGContextBeginPath(aContext); diff --git a/AppKit/CoreGraphics/CGContextCanvas.j b/AppKit/CoreGraphics/CGContextCanvas.j index 3c2115dc4..f5a59117d 100644 --- a/AppKit/CoreGraphics/CGContextCanvas.j +++ b/AppKit/CoreGraphics/CGContextCanvas.j @@ -140,7 +140,7 @@ function CGContextAddCurveToPoint(aContext, cp1x, cp1y, cp2x, cp2y, x, y) function CGContextAddLines(aContext, points, count) { // implementation mirrors that of CGPathAddLines() - if (count === null || count === undefined) + if (count == null) count = points.length; if (count < 1) @@ -234,7 +234,7 @@ function CGContextAddQuadCurveToPoint(aContext, cpx, cpy, x, y) function CGContextAddRects(aContext, rects, count) { - if (count === null || count === undefined) + if (count == null) count = rects.length; for (var i = 0; i < count; ++i) @@ -297,7 +297,7 @@ function CGContextFillRect(aContext, aRect) function CGContextFillRects(aContext, rects, count) { - if (count === null || count === undefined) + if (count == null) count = rects.length; for (var i = 0; i < count; ++i) @@ -333,7 +333,7 @@ function CGContextClipToRect(aContext, aRect) function CGContextClipToRects(aContext, rects, count) { - if (count === null || count === undefined) + if (count == null) count = rects.length; _CGContextBeginPathCanvas(aContext); diff --git a/AppKit/CoreGraphics/CGGradient.j b/AppKit/CoreGraphics/CGGradient.j index aea212219..59838c62b 100644 --- a/AppKit/CoreGraphics/CGGradient.j +++ b/AppKit/CoreGraphics/CGGradient.j @@ -30,7 +30,7 @@ kCGGradientDrawsAfterEndLocation = 1 << 1; function CGGradientCreateWithColorComponents(aColorSpace, components, locations, count) { - if (locations === undefined || locations === NULL) + if (locations == NULL) { var num_of_colors = components.length / 4, locations = []; @@ -39,7 +39,7 @@ function CGGradientCreateWithColorComponents(aColorSpace, components, locations, locations.push( idx / (num_of_colors - 1) ); } - if (count === undefined || count === NULL) + if (count == NULL) count = locations.length; var colors = []; diff --git a/AppKit/CoreGraphics/CGPath.j b/AppKit/CoreGraphics/CGPath.j index b01d92dfc..6be1b4764 100644 --- a/AppKit/CoreGraphics/CGPath.j +++ b/AppKit/CoreGraphics/CGPath.j @@ -188,7 +188,7 @@ function CGPathAddCurveToPoint(aPath, aTransform, cp1x, cp1y, cp2x, cp2y, x, y) function CGPathAddLines(aPath, aTransform, points, count) { - if (count === null || count === undefined) + if (count == null) count = points.length; if (!aPath || count < 1) @@ -284,7 +284,7 @@ function CGPathAddRects(aPath, aTransform, rects, count) { var i = 0; - if (count === NULL) + if (count == NULL) var count = rects.length; for (; i < count; ++i) diff --git a/AppKit/Platform/DOM/CPPlatform.j b/AppKit/Platform/DOM/CPPlatform.j index 0ab47058d..28531a684 100644 --- a/AppKit/Platform/DOM/CPPlatform.j +++ b/AppKit/Platform/DOM/CPPlatform.j @@ -156,7 +156,7 @@ var screenNeedsInitialization = NO, platformWindowEnumerator = [platformWindows objectEnumerator], platformWindow = nil; - while ((platformWindow = [platformWindowEnumerator nextObject]) !== nil) + while ((platformWindow = [platformWindowEnumerator nextObject]) != nil) { if (platformWindow != primaryPlatformWindow) [platformWindow orderOut:self]; diff --git a/AppKit/_CPImageAndTextView.j b/AppKit/_CPImageAndTextView.j index e5c1b84ee..6c754a448 100644 --- a/AppKit/_CPImageAndTextView.j +++ b/AppKit/_CPImageAndTextView.j @@ -602,7 +602,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0, } } - var needsDOMImageElement = _image !== nil && _imagePosition !== CPNoImage, + var needsDOMImageElement = _image != nil && _imagePosition !== CPNoImage, hasDOMImageElement = !!_DOMImageElement, // For CSS theming isCSSBasedImage = [_image isCSSBased], diff --git a/AppKit/_CPPopUpList.j b/AppKit/_CPPopUpList.j index 7dfa0a010..56421851e 100644 --- a/AppKit/_CPPopUpList.j +++ b/AppKit/_CPPopUpList.j @@ -523,7 +523,7 @@ var ListColumnIdentifier = @"1"; { var value = [self selectedObjectValue]; - return value !== nil ? [_dataSource list:self stringValueForObjectValue:value] : nil; + return value != nil ? [_dataSource list:self stringValueForObjectValue:value] : nil; } /*! diff --git a/AppKit/_CPPopoverWindow.j b/AppKit/_CPPopoverWindow.j index 159b26a6c..88c69bb34 100644 --- a/AppKit/_CPPopoverWindow.j +++ b/AppKit/_CPPopoverWindow.j @@ -264,7 +264,7 @@ var _CPPopoverWindow_shouldClose_ = 1 << 4, originTop.x += platformRect.size.width / 2.0 - frameSize.width / 2.0; originTop.y -= frameSize.height; - var requestedEdge = (anEdge !== nil) ? anEdge : CPMaxXEdge, + var requestedEdge = (anEdge != nil) ? anEdge : CPMaxXEdge, requestedOrigin; switch (requestedEdge) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b32c82d6e..6e160c509 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -394,7 +394,7 @@ Every brace gets its own line, very simple to remember: In JavaScript, the null object value should be written as null. In Objective-J, it should be written as `nil` when the variable refers to an object, and `Nil` when it refers to a `Class`. Objective-J `BOOL` values should be written as `YES` and `NO`. -Tests for `true/false`, `null/non-null`, and zero/non-zero should all be done without equality comparisons, except for cases when a value could be both 0 or `null` (or another "falsey" value). In this case, the comparison should be preceded by a comment explaining the distinction. +Tests for `true/false`, `null/non-null`, and zero/non-zero should all be done without equality comparisons, except for cases when a value could be both 0, "" or `null` (or another "falsey" value). In this case, the comparison should be preceded by a comment explaining the distinction. When comparing with nil/null always use '==' / '!=' as the value cound also be undefined. ##### Right: @@ -407,8 +407,8 @@ Tests for `true/false`, `null/non-null`, and zero/non-zero should all be done wi if (!count) return; - // object is an ID number, so 0 is OK, but null is not. - if (object === null) + // object is an ID number, so 0 is OK, but null/undefined is not. + if (object == null) return; ##### Wrong: @@ -416,13 +416,13 @@ Tests for `true/false`, `null/non-null`, and zero/non-zero should all be done wi if (condition == true) doIt(); - if (ptr == NULL) + if (ptr === NULL) return; if (count == 0) return; - if (object == null) + if (object === null) return; --- diff --git a/Foundation/CPArray+KVO.j b/Foundation/CPArray+KVO.j index b4a87bc7f..f28d21b09 100644 --- a/Foundation/CPArray+KVO.j +++ b/Foundation/CPArray+KVO.j @@ -458,11 +458,11 @@ enumerator = [self objectEnumerator], object; - while ((object = [enumerator nextObject]) !== nil) + while ((object = [enumerator nextObject]) != nil) { var value = [object valueForKey:aKey]; - if (value === nil || value === undefined) + if (value == nil) value = [CPNull null]; newArray.push(value); @@ -499,11 +499,11 @@ enumerator = [self objectEnumerator], object; - while ((object = [enumerator nextObject]) !== nil) + while ((object = [enumerator nextObject]) != nil) { var value = [object valueForKeyPath:aKeyPath]; - if (value === nil || value === undefined) + if (value == nil) value = [CPNull null]; newArray.push(value); @@ -518,7 +518,7 @@ var enumerator = [self objectEnumerator], object; - while ((object = [enumerator nextObject]) !== nil) + while ((object = [enumerator nextObject]) != nil) [object setValue:aValue forKey:aKey]; } @@ -527,7 +527,7 @@ var enumerator = [self objectEnumerator], object; - while ((object = [enumerator nextObject]) !== nil) + while ((object = [enumerator nextObject]) != nil) [object setValue:aValue forKeyPath:aKeyPath]; } diff --git a/Foundation/CPArray/CPMutableArray.j b/Foundation/CPArray/CPMutableArray.j index 3815919e2..9d37200ca 100644 --- a/Foundation/CPArray/CPMutableArray.j +++ b/Foundation/CPArray/CPMutableArray.j @@ -527,10 +527,10 @@ var sortArrayUsingJSDescriptors = function(a, d) key = dd.k; value1 = C1[key]; value2 = C2[key]; - if (value1 === nil || value1 === cpNull) - o = value2 === nil || value2 === cpNull ? CPOrderedSame : CPOrderedAscending; + if (value1 == nil || value1 === cpNull) + o = value2 == nil || value2 === cpNull ? CPOrderedSame : CPOrderedAscending; else - o = value2 === nil || value2 === cpNull ? CPOrderedDescending : value1.isa.objj_msgSend1(value1, dd.s, value2); + o = value2 == nil || value2 === cpNull ? CPOrderedDescending : value1.isa.objj_msgSend1(value1, dd.s, value2); if (o && !dd.a) o = -o; diff --git a/Foundation/CPArray/_CPArray.j b/Foundation/CPArray/_CPArray.j index 9a18fc879..0f0bb2ee4 100755 --- a/Foundation/CPArray/_CPArray.j +++ b/Foundation/CPArray/_CPArray.j @@ -708,7 +708,7 @@ Returns a hash for the object. Unlike Cocoa, the hash value does not take conten var count = [self count], otherCount = [anArray count]; - if (anArray === nil || count !== otherCount) + if (anArray == nil || count !== otherCount) return NO; var index = 0; diff --git a/Foundation/CPArray/_CPJavaScriptArray.j b/Foundation/CPArray/_CPJavaScriptArray.j index 8822ed0b4..41653919b 100644 --- a/Foundation/CPArray/_CPJavaScriptArray.j +++ b/Foundation/CPArray/_CPJavaScriptArray.j @@ -82,7 +82,7 @@ var concat = Array.prototype.concat, count = arguments.length; for (; index < count; ++index) - if (arguments[index] === nil) + if (arguments[index] == nil) break; return slice.call(arguments, 2, index); diff --git a/Foundation/CPAttributedString.j b/Foundation/CPAttributedString.j index 3416b64bc..b43b43d94 100755 --- a/Foundation/CPAttributedString.j +++ b/Foundation/CPAttributedString.j @@ -141,7 +141,7 @@ // private method - (unsigned)_indexOfEntryWithIndex:(unsigned)anIndex { - if (anIndex < 0 || anIndex > _string.length || anIndex === undefined) + if (anIndex < 0 || anIndex > _string.length || anIndex == nil) return CPNotFound; // find the range entry that contains anIndex. diff --git a/Foundation/CPCharacterSet.j b/Foundation/CPCharacterSet.j index 6472b618c..9d52f6175 100644 --- a/Foundation/CPCharacterSet.j +++ b/Foundation/CPCharacterSet.j @@ -243,7 +243,7 @@ var CPCharacterSetInvertedKey = @"CPCharacterSetInvertedKey"; enu = [_ranges objectEnumerator], range; - while ((range = [enu nextObject]) !== nil) + while ((range = [enu nextObject]) != nil) { if (CPLocationInRange(c, range)) return !_inverted; @@ -265,7 +265,7 @@ var CPCharacterSetInvertedKey = @"CPCharacterSetInvertedKey"; var enu = [_ranges objectEnumerator], range; - while ((range = [enu nextObject]) !== nil) + while ((range = [enu nextObject]) != nil) { if (!CPEmptyRange(range)) return YES; diff --git a/Foundation/CPDictionary.j b/Foundation/CPDictionary.j index 15f7b83a7..1238f1e09 100755 --- a/Foundation/CPDictionary.j +++ b/Foundation/CPDictionary.j @@ -127,7 +127,7 @@ var CPDictionaryMaxDescriptionRecursion = 10; var value = object[key]; - if (value === null) + if (value == null) { [dictionary setObject:[CPNull null] forKey:key]; continue; @@ -147,7 +147,7 @@ var CPDictionaryMaxDescriptionRecursion = 10; { var thisValue = value[i]; - if (thisValue === null) + if (thisValue == null) { newValue.push([CPNull null]); } @@ -234,10 +234,10 @@ var CPDictionaryMaxDescriptionRecursion = 10; var value = objects[i], key = keyArray[i]; - if (value === nil) + if (value == nil) [CPException raise:CPInvalidArgumentException reason:@"Attempt to insert nil object from objects[" + i + @"]"]; - if (key === nil) + if (key == nil) [CPException raise:CPInvalidArgumentException reason:@"Attempt to insert nil key from keys[" + i + @"]"]; [self setObject:value forKey:key]; @@ -278,10 +278,10 @@ var CPDictionaryMaxDescriptionRecursion = 10; var key = arguments[argCount--], value = arguments[argCount]; - if (value === nil) + if (value == nil) [CPException raise:CPInvalidArgumentException reason:@"Attempt to insert nil object from objects[" + ((argCount / 2) - 1) + @"]"]; - if (key === nil) + if (key == nil) [CPException raise:CPInvalidArgumentException reason:@"Attempt to insert nil key from keys[" + ((argCount / 2) - 1) + @"]"]; [self setObject:value forKey:key]; @@ -593,10 +593,10 @@ var CPDictionaryMaxDescriptionRecursion = 10; */ - (void)setObject:(id)anObject forKey:(id)aKey { - if (aKey === nil) + if (aKey == nil) [CPException raise:CPInvalidArgumentException reason:@"key cannot be nil"]; - if (anObject === nil) + if (anObject == nil) [CPException raise:CPInvalidArgumentException reason:@"object cannot be nil (key: " + aKey + @")"]; self.setValueForKey(aKey, anObject); @@ -650,7 +650,7 @@ var CPDictionaryMaxDescriptionRecursion = 10; - (BOOL)containsKey:(id)aKey { var value = [self objectForKey:aKey]; - return ((value !== nil) && (value !== undefined)); + return (value != nil); } - (void)enumerateKeysAndObjectsUsingBlock:(Function /*(id aKey, id anObject, @ref BOOL stop)*/)aFunction @@ -730,7 +730,7 @@ var CPDictionaryMaxDescriptionRecursion = 10; { var key = [_keyEnumerator nextObject]; - if (key === nil) + if (key == nil) return nil; return [_dictionary objectForKey:key]; diff --git a/Foundation/CPFormatter.j b/Foundation/CPFormatter.j index e0d72d43c..15c5bffe6 100644 --- a/Foundation/CPFormatter.j +++ b/Foundation/CPFormatter.j @@ -159,7 +159,7 @@ @deref(aPartialStringRef) = newString; // If a new string is passed back, the selection is always put at the end - if (newString !== nil) + if (newString != nil) @deref(aProposedSelectedRangeRef) = CPMakeRange(newString.length, 0); } diff --git a/Foundation/CPKeyValueCoding.j b/Foundation/CPKeyValueCoding.j index b67d78b88..374ac5717 100644 --- a/Foundation/CPKeyValueCoding.j +++ b/Foundation/CPKeyValueCoding.j @@ -151,7 +151,7 @@ var CPObjectAccessorsForClassKey = @"$CPObjectAccessorsForClassKey", var key = keys[index], value = [self valueForKey:key]; - if (value === nil) + if (value == nil) [dictionary setObject:[CPNull null] forKey:key]; else @@ -248,7 +248,7 @@ var CPObjectAccessorsForClassKey = @"$CPObjectAccessorsForClassKey", key, keyEnumerator = [keyedValues keyEnumerator]; - while ((key = [keyEnumerator nextObject]) !== nil) + while ((key = [keyEnumerator nextObject]) != nil) { value = [keyedValues objectForKey: key]; @@ -286,7 +286,7 @@ var CPObjectAccessorsForClassKey = @"$CPObjectAccessorsForClassKey", - (void)setValue:(id)aValue forKey:(CPString)aKey { - if (aValue !== nil) + if (aValue != nil) [self setObject:aValue forKey:aKey]; else diff --git a/Foundation/CPKeyValueObserving.j b/Foundation/CPKeyValueObserving.j index c4ddf0edb..f789fcbf9 100644 --- a/Foundation/CPKeyValueObserving.j +++ b/Foundation/CPKeyValueObserving.j @@ -923,7 +923,7 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOpti { var oldValue = [_targetObject valueForKey:aKey]; - if (oldValue === nil || oldValue === undefined) + if (oldValue == nil) oldValue = [CPNull null]; [changes setObject:oldValue forKey:CPKeyValueChangeOldKey]; @@ -1005,7 +1005,7 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOpti { var newValue = [_targetObject valueForKey:aKey]; - if (newValue === nil || newValue === undefined) + if (newValue == nil) newValue = [CPNull null]; [changes setObject:newValue forKey:CPKeyValueChangeNewKey]; diff --git a/Foundation/CPKeyedArchiver.j b/Foundation/CPKeyedArchiver.j index 20bb7b4be..c9e2f10bc 100644 --- a/Foundation/CPKeyedArchiver.j +++ b/Foundation/CPKeyedArchiver.j @@ -395,7 +395,7 @@ var _CPKeyedArchiverStringClass = Nil, keys = [aDictionary keyEnumerator], references = @{}; - while ((key = [keys nextObject]) !== nil) + while ((key = [keys nextObject]) != nil) [references setObject:_CPKeyedArchiverEncodeObject(self, [aDictionary objectForKey:key], NO) forKey:key]; [_plistObject setObject:references forKey:aKey]; @@ -471,7 +471,7 @@ var _CPKeyedArchiverEncodeObject = function(self, anObject, isConditional) // We wrap primitive JavaScript objects in a unique subclass of CPValue. // This way, when we unarchive, we know to unwrap it, since // _CPKeyedArchiverValue should not be used anywhere else. - if (anObject !== nil && anObject !== undefined && !anObject.isa) + if (anObject != nil && !anObject.isa) anObject = [_CPKeyedArchiverValue valueWithJSObject:anObject]; // Get the proper replacement object @@ -479,8 +479,8 @@ var _CPKeyedArchiverEncodeObject = function(self, anObject, isConditional) object = [self._replacementObjects objectForKey:GUID]; // If a replacement object doesn't exist, then actually ask for one. - // Explicitly compare to nil because object could be === 0. - if (object === nil) + // Explicitly compare to nil and undefined because object could be === 0. + if (object == nil) { object = [anObject replacementObjectForKeyedArchiver:self]; @@ -507,8 +507,8 @@ var _CPKeyedArchiverEncodeObject = function(self, anObject, isConditional) // If we still don't have an object by this point, then return a // reference to the null object. - // Explicitly compare to nil because object could be === 0. - if (object === nil) + // Explicitly compare to nil and undefined because object could be === 0. + if (object == nil) return _CPKeyedArchiverNullReference; // If not, then grab the object's UID @@ -517,13 +517,13 @@ var _CPKeyedArchiverEncodeObject = function(self, anObject, isConditional) // If this object doesn't have a unique index in the object table yet, // then it also hasn't been properly encoded. We explicitly compare // index to nil since it could be 0, which would also evaluate to false. - if (UID === nil) + if (UID == nil) { // If it is being conditionally encoded, then if (isConditional) { // If we haven't already noted this conditional object... - if ((UID = [self._conditionalUIDs objectForKey:GUID]) === nil) + if ((UID = [self._conditionalUIDs objectForKey:GUID]) == nil) { // Use the null object as a placeholder. [self._conditionalUIDs setObject:UID = [self._plistObjects count] forKey:GUID]; @@ -581,7 +581,7 @@ var _CPKeyedArchiverEncodeObject = function(self, anObject, isConditional) UID = [self._conditionalUIDs objectForKey:GUID]; // If this object WAS previously encoded conditionally... - if (UID !== nil) + if (UID != nil) { [self._UIDs setObject:UID forKey:GUID]; [self._plistObjects replaceObjectAtIndex:UID withObject:plistObject]; diff --git a/Foundation/CPKeyedUnarchiver.j b/Foundation/CPKeyedUnarchiver.j index 4f35f66ff..80da3ca60 100644 --- a/Foundation/CPKeyedUnarchiver.j +++ b/Foundation/CPKeyedUnarchiver.j @@ -253,7 +253,7 @@ var CPArrayClass = Ni { var f = [self decodeObjectForKey:aKey]; - return f === nil ? 0.0 : f; + return f == nil ? 0.0 : f; } /* @@ -265,7 +265,7 @@ var CPArrayClass = Ni { var d = [self decodeObjectForKey:aKey]; - return d === nil ? 0.0 : d; + return d == nil ? 0.0 : d; } /* @@ -277,7 +277,7 @@ var CPArrayClass = Ni { var i = [self decodeObjectForKey:aKey]; - return i === nil ? 0 : i; + return i == nil ? 0 : i; } /* diff --git a/Foundation/CPNotificationCenter.j b/Foundation/CPNotificationCenter.j index 5f8ff94da..aa581a9a7 100644 --- a/Foundation/CPNotificationCenter.j +++ b/Foundation/CPNotificationCenter.j @@ -136,7 +136,7 @@ var CPNotificationDefaultCenter = nil; var name = nil, names = [_namedRegistries keyEnumerator]; - while ((name = [names nextObject]) !== nil) + while ((name = [names nextObject]) != nil) [[_namedRegistries objectForKey:name] removeObserver:anObserver object:nil]; [_unnamedRegistry removeObserver:anObserver object:nil]; @@ -155,7 +155,7 @@ var CPNotificationDefaultCenter = nil; var name = nil, names = [_namedRegistries keyEnumerator]; - while ((name = [names nextObject]) !== nil) + while ((name = [names nextObject]) != nil) [[_namedRegistries objectForKey:name] removeObserver:anObserver object:anObject]; [_unnamedRegistry removeObserver:anObserver object:anObject]; @@ -258,13 +258,13 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */ keys = [_objectObservers keyEnumerator]; // Iterate through every set of observers - while ((key = [keys nextObject]) !== nil) + while ((key = [keys nextObject]) != nil) { var observers = [_objectObservers objectForKey:key], observer = nil, observersEnumerator = [observers objectEnumerator]; - while ((observer = [observersEnumerator nextObject]) !== nil) + while ((observer = [observersEnumerator nextObject]) != nil) if ([observer observer] == anObserver || ([observer block] && [anObserver respondsToSelector:@selector(block)] && [observer block] == [anObserver block])) [observers removeObject:observer]; @@ -280,7 +280,7 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */ observer = nil, observersEnumerator = [observers objectEnumerator]; - while ((observer = [observersEnumerator nextObject]) !== nil) + while ((observer = [observersEnumerator nextObject]) != nil) if ([observer observer] == anObserver || ([observer block] && [anObserver respondsToSelector:@selector(block)] && [observer block] == [anObserver block])) [observers removeObject:observer]; @@ -311,7 +311,7 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */ observer = nil, observersEnumerator = [observers objectEnumerator]; - while ((observer = [observersEnumerator nextObject]) !== nil) + while ((observer = [observersEnumerator nextObject]) != nil) { // CPSet containsObject is N(1) so this is a fast check. if ([currentObservers containsObject:observer]) @@ -328,7 +328,7 @@ var _CPNotificationCenterPostNotification = function(/* CPNotificationCenter */ var observers = [currentObservers copy], observersEnumerator = [observers objectEnumerator]; - while ((observer = [observersEnumerator nextObject]) !== nil) + while ((observer = [observersEnumerator nextObject]) != nil) { // CPSet containsObject is N(1) so this is a fast check. if ([currentObservers containsObject:observer]) diff --git a/Foundation/CPNumber.j b/Foundation/CPNumber.j index ef641b1ec..0a45c2bd2 100644 --- a/Foundation/CPNumber.j +++ b/Foundation/CPNumber.j @@ -314,7 +314,7 @@ FIXME: Do we need this? - (CPComparisonResult)compare:(CPNumber)aNumber { - if (aNumber === nil || aNumber['isa'] === CPNull) + if (aNumber == nil || aNumber['isa'] === CPNull) [CPException raise:CPInvalidArgumentException reason:"nil argument"]; if (self > aNumber) diff --git a/Foundation/CPNumberFormatter.j b/Foundation/CPNumberFormatter.j index 52737fc1c..7645d0052 100644 --- a/Foundation/CPNumberFormatter.j +++ b/Foundation/CPNumberFormatter.j @@ -205,9 +205,9 @@ var NumberRegex = new RegExp('(-)?(\\d*)(\\.(\\d*))?'); // this will return false if we've received anything but a number, most likely NaN if (!isFinite(value)) error = @"Value is not a number"; - else if (_minimum !== nil && value < _minimum) + else if (_minimum != nil && value < _minimum) error = @"Value is less than the minimum allowed value"; - else if (_maximum !== nil && value > _maximum) + else if (_maximum != nil && value > _maximum) error = @"Value is greater than the maximum allowed value"; if (error) diff --git a/Foundation/CPPredicate/CPComparisonPredicate.j b/Foundation/CPPredicate/CPComparisonPredicate.j index 338a4e7f3..15a44be33 100644 --- a/Foundation/CPPredicate/CPComparisonPredicate.j +++ b/Foundation/CPPredicate/CPComparisonPredicate.j @@ -275,7 +275,7 @@ if (self === anObject) return YES; - if (anObject === nil || anObject.isa !== self.isa || _modifier !== [anObject comparisonPredicateModifier] || _type !== [anObject predicateOperatorType] || _options !== [anObject options] || _customSelector !== [anObject customSelector] || ![_left isEqual:[anObject leftExpression]] || ![_right isEqual:[anObject rightExpression]]) + if (anObject == nil || anObject.isa !== self.isa || _modifier !== [anObject comparisonPredicateModifier] || _type !== [anObject predicateOperatorType] || _options !== [anObject options] || _customSelector !== [anObject customSelector] || ![_left isEqual:[anObject leftExpression]] || ![_right isEqual:[anObject rightExpression]]) return NO; return YES; @@ -388,7 +388,7 @@ result = (_modifier == CPAllPredicateModifier), value; - while ((value = [e nextObject]) !== nil) + while ((value = [e nextObject]) != nil) { var eval = [self _evaluateValue:value rightValue:rightValue]; diff --git a/Foundation/CPPredicate/CPCompoundPredicate.j b/Foundation/CPPredicate/CPCompoundPredicate.j index a38f3b065..600691081 100644 --- a/Foundation/CPPredicate/CPCompoundPredicate.j +++ b/Foundation/CPPredicate/CPCompoundPredicate.j @@ -215,7 +215,7 @@ if (self === anObject) return YES; - if (anObject === nil || anObject.isa !== self.isa || _type !== [anObject compoundPredicateType] || ![_predicates isEqualToArray:[anObject subpredicates]]) + if (anObject == nil || anObject.isa !== self.isa || _type !== [anObject compoundPredicateType] || ![_predicates isEqualToArray:[anObject subpredicates]]) return NO; return YES; diff --git a/Foundation/CPPredicate/_CPAggregateExpression.j b/Foundation/CPPredicate/_CPAggregateExpression.j index e141b1915..3129f6c27 100644 --- a/Foundation/CPPredicate/_CPAggregateExpression.j +++ b/Foundation/CPPredicate/_CPAggregateExpression.j @@ -43,7 +43,7 @@ if (self === object) return YES; - if (object === nil || object.isa !== self.isa || ![[object collection] isEqual:_aggregate]) + if (object == nil || object.isa !== self.isa || ![[object collection] isEqual:_aggregate]) return NO; return YES; @@ -58,7 +58,7 @@ } - (CPString)description -{ +{ var descriptions = [_aggregate arrayByApplyingBlock:function(exp) { return [exp description]; diff --git a/Foundation/CPPredicate/_CPBlockExpression.j b/Foundation/CPPredicate/_CPBlockExpression.j index 846c4f418..733e55240 100644 --- a/Foundation/CPPredicate/_CPBlockExpression.j +++ b/Foundation/CPPredicate/_CPBlockExpression.j @@ -45,7 +45,7 @@ if (self === object) return YES; - if (object === nil || object.isa !== self.isa || [object expressionBlock] !== _block || ![[object arguments] isEqual:_arguments]) + if (object == nil || object.isa !== self.isa || [object expressionBlock] !== _block || ![[object arguments] isEqual:_arguments]) return NO; return YES; diff --git a/Foundation/CPPredicate/_CPConditionalExpression.j b/Foundation/CPPredicate/_CPConditionalExpression.j index 8fc544580..683b3b10b 100644 --- a/Foundation/CPPredicate/_CPConditionalExpression.j +++ b/Foundation/CPPredicate/_CPConditionalExpression.j @@ -47,7 +47,7 @@ if (self === object) return YES; - if (object === nil || object.isa !== self.isa || ![[object predicate] isEqual:_predicate] || ![[object trueExpression] isEqual:_trueExpression] || ![[object falseExpression] isEqual:_falseExpression]) + if (object == nil || object.isa !== self.isa || ![[object predicate] isEqual:_predicate] || ![[object trueExpression] isEqual:_trueExpression] || ![[object falseExpression] isEqual:_falseExpression]) return NO; return YES; diff --git a/Foundation/CPPredicate/_CPConstantValueExpression.j b/Foundation/CPPredicate/_CPConstantValueExpression.j index 1c1bbbce9..4c94f2030 100644 --- a/Foundation/CPPredicate/_CPConstantValueExpression.j +++ b/Foundation/CPPredicate/_CPConstantValueExpression.j @@ -45,7 +45,7 @@ if (self === object) return YES; - if (object === nil || object.isa !== self.isa || ![[object constantValue] isEqual:_value]) + if (object == nil || object.isa !== self.isa || ![[object constantValue] isEqual:_value]) return NO; return YES; diff --git a/Foundation/CPPredicate/_CPFunctionExpression.j b/Foundation/CPPredicate/_CPFunctionExpression.j index 1ae0e269e..11a77e32a 100644 --- a/Foundation/CPPredicate/_CPFunctionExpression.j +++ b/Foundation/CPPredicate/_CPFunctionExpression.j @@ -72,7 +72,7 @@ if (self === object) return YES; - if (object === nil || object.isa !== self.isa || ![[object _function] isEqual:_selector] || ![[object operand] isEqual:_operand] || ![[object arguments] isEqualToArray:_arguments]) + if (object == nil || object.isa !== self.isa || ![[object _function] isEqual:_selector] || ![[object operand] isEqual:_operand] || ![[object arguments] isEqualToArray:_arguments]) return NO; return YES; diff --git a/Foundation/CPPredicate/_CPKeyPathExpression.j b/Foundation/CPPredicate/_CPKeyPathExpression.j index 0f9ece8b6..055290b1e 100644 --- a/Foundation/CPPredicate/_CPKeyPathExpression.j +++ b/Foundation/CPPredicate/_CPKeyPathExpression.j @@ -51,7 +51,7 @@ if (object === self) return YES; - if (object === nil || object.isa !== self.isa || ![[object keyPath] isEqualToString:[self keyPath]]) + if (object == nil || object.isa !== self.isa || ![[object keyPath] isEqualToString:[self keyPath]]) return NO; return YES; diff --git a/Foundation/CPPredicate/_CPPredicate.j b/Foundation/CPPredicate/_CPPredicate.j index e4010d086..cf1628990 100644 --- a/Foundation/CPPredicate/_CPPredicate.j +++ b/Foundation/CPPredicate/_CPPredicate.j @@ -190,7 +190,7 @@ if (self === anObject) return YES; - if (anObject === nil || self.isa !== anObject.isa || _value !== [anObject evaluateWithObject:nil]) + if (anObject == nil || self.isa !== anObject.isa || _value !== [anObject evaluateWithObject:nil]) return NO; return YES; diff --git a/Foundation/CPPredicate/_CPSetExpression.j b/Foundation/CPPredicate/_CPSetExpression.j index 707486b32..45bca2589 100644 --- a/Foundation/CPPredicate/_CPSetExpression.j +++ b/Foundation/CPPredicate/_CPSetExpression.j @@ -47,7 +47,7 @@ if (self === object) return YES; - if (object === nil || object.isa !== self.isa || ![[object leftExpression] isEqual:_left] || ![[object rightExpression] isEqual:_right]) + if (object == nil || object.isa !== self.isa || ![[object leftExpression] isEqual:_left] || ![[object rightExpression] isEqual:_right]) return NO; return YES; diff --git a/Foundation/CPPredicate/_CPSubqueryExpression.j b/Foundation/CPPredicate/_CPSubqueryExpression.j index 0f51572ec..43e8abed0 100644 --- a/Foundation/CPPredicate/_CPSubqueryExpression.j +++ b/Foundation/CPPredicate/_CPSubqueryExpression.j @@ -75,7 +75,7 @@ if (self === object) return YES; - if (object === nil || object.isa !== self.isa || ![_collection isEqual:[object collection]] || ![_variableExpression isEqual:[object variableExpression]] || ![_subpredicate isEqual:[object predicate]]) + if (object == nil || object.isa !== self.isa || ![_collection isEqual:[object collection]] || ![_variableExpression isEqual:[object variableExpression]] || ![_subpredicate isEqual:[object predicate]]) return NO; return YES; diff --git a/Foundation/CPPredicate/_CPVariableExpression.j b/Foundation/CPPredicate/_CPVariableExpression.j index a33911222..94d78e7b6 100644 --- a/Foundation/CPPredicate/_CPVariableExpression.j +++ b/Foundation/CPPredicate/_CPVariableExpression.j @@ -48,7 +48,7 @@ if (self === object) return YES; - if (object === nil || object.isa !== self.isa || ![[object variable] isEqual:_variable]) + if (object == nil || object.isa !== self.isa || ![[object variable] isEqual:_variable]) return NO; return YES; diff --git a/Foundation/CPRunLoop.j b/Foundation/CPRunLoop.j index 4afd72109..6867a4d8d 100644 --- a/Foundation/CPRunLoop.j +++ b/Foundation/CPRunLoop.j @@ -373,7 +373,7 @@ var CPRunLoopLastNativeRunLoop = 0; _didAddTimer = NO; // Cancel existing window.setTimeout - if (_nativeTimersForModes[aMode] !== nil) + if (_nativeTimersForModes[aMode] != nil) { window.clearNativeTimeout(_nativeTimersForModes[aMode]); @@ -400,7 +400,7 @@ var CPRunLoopLastNativeRunLoop = 0; // Timer may or may not still be valid if (timer._isValid) - nextFireDate = (nextFireDate === nil) ? timer._fireDate : [nextFireDate earlierDate:timer._fireDate]; + nextFireDate = (nextFireDate == nil) ? timer._fireDate : [nextFireDate earlierDate:timer._fireDate]; else { @@ -425,7 +425,7 @@ var CPRunLoopLastNativeRunLoop = 0; var timer = newTimers[index]; if ([timer isValid]) - nextFireDate = (nextFireDate === nil) ? timer._fireDate : [nextFireDate earlierDate:timer._fireDate]; + nextFireDate = (nextFireDate == nil) ? timer._fireDate : [nextFireDate earlierDate:timer._fireDate]; else newTimers.splice(index, 1); } @@ -438,7 +438,7 @@ var CPRunLoopLastNativeRunLoop = 0; _nextTimerFireDatesForModes[aMode] = nextFireDate; //initiate a new window.setTimeout if there are any timers - if (_nextTimerFireDatesForModes[aMode] !== nil) + if (_nextTimerFireDatesForModes[aMode] != nil) _nativeTimersForModes[aMode] = window.setNativeTimeout(function() { _effectiveDate = nextFireDate; diff --git a/Foundation/CPSet+KVO.j b/Foundation/CPSet+KVO.j index d4648fe10..322828c49 100644 --- a/Foundation/CPSet+KVO.j +++ b/Foundation/CPSet+KVO.j @@ -221,7 +221,7 @@ var object, objectEnumerator = [objects objectEnumerator]; - while ((object = [objectEnumerator nextObject]) !== nil) + while ((object = [objectEnumerator nextObject]) != nil) _add(_proxyObject, _addSEL, object); } else @@ -241,7 +241,7 @@ var object, objectEnumerator = [aSet objectEnumerator]; - while ((object = [objectEnumerator nextObject]) !== nil) + while ((object = [objectEnumerator nextObject]) != nil) _add(_proxyObject, _addSEL, object); } else @@ -278,7 +278,7 @@ var object, objectEnumerator = [aSet objectEnumerator]; - while ((object = [objectEnumerator nextObject]) !== nil) + while ((object = [objectEnumerator nextObject]) != nil) _remove(_proxyObject, _removeSEL, object); } else @@ -301,7 +301,7 @@ var object, objectEnumerator = [objects objectEnumerator]; - while ((object = [objectEnumerator nextObject]) !== nil) + while ((object = [objectEnumerator nextObject]) != nil) _remove(_proxyObject, _removeSEL, object); } else @@ -324,7 +324,7 @@ var object, objectEnumerator = [[[self _representedObject] copy] objectEnumerator]; - while ((object = [objectEnumerator nextObject]) !== nil) + while ((object = [objectEnumerator nextObject]) != nil) _remove(_proxyObject, _removeSEL, object); } else @@ -414,11 +414,11 @@ containedObjectValue, containedObjectEnumerator = [self objectEnumerator]; - while ((containedObject = [containedObjectEnumerator nextObject]) !== nil) + while ((containedObject = [containedObjectEnumerator nextObject]) != nil) { containedObjectValue = [containedObject valueForKeyPath:aKeyPath]; - if (containedObjectValue === nil || containedObjectValue === undefined) + if (containedObjectValue == nil) containedObjectValue = [CPNull null]; [valuesForKeySet addObject:containedObjectValue]; @@ -433,7 +433,7 @@ var containedObject, containedObjectEnumerator = [self objectEnumerator]; - while ((containedObject = [containedObjectEnumerator nextObject]) !== nil) + while ((containedObject = [containedObjectEnumerator nextObject]) != nil) [containedObject setValue:aValue forKey:aKey]; } diff --git a/Foundation/CPSet/CPMutableSet.j b/Foundation/CPSet/CPMutableSet.j index a70c74c55..f42bac3ed 100644 --- a/Foundation/CPSet/CPMutableSet.j +++ b/Foundation/CPSet/CPMutableSet.j @@ -37,7 +37,7 @@ var object, objectEnumerator = [self objectEnumerator]; - while ((object = [objectEnumerator nextObject]) !== nil) + while ((object = [objectEnumerator nextObject]) != nil) if (![aPredicate evaluateWithObject:object]) [self removeObject:object]; } @@ -72,7 +72,7 @@ var object, objectEnumerator = [self objectEnumerator]; - while ((object = [objectEnumerator nextObject]) !== nil) + while ((object = [objectEnumerator nextObject]) != nil) [self removeObject:object]; } @@ -97,7 +97,7 @@ var object, objectEnumerator = [aSet objectEnumerator]; - while ((object = [objectEnumerator nextObject]) !== nil) + while ((object = [objectEnumerator nextObject]) != nil) [self addObject:object]; } @@ -110,7 +110,7 @@ var object, objectEnumerator = [aSet objectEnumerator]; - while ((object = [objectEnumerator nextObject]) !== nil) + while ((object = [objectEnumerator nextObject]) != nil) [self removeObject:object]; } @@ -124,7 +124,7 @@ objectEnumerator = [self objectEnumerator], objectsToRemove = []; - while ((object = [objectEnumerator nextObject]) !== nil) + while ((object = [objectEnumerator nextObject]) != nil) if (![aSet containsObject:object]) objectsToRemove.push(object); diff --git a/Foundation/CPSet/_CPConcreteMutableSet.j b/Foundation/CPSet/_CPConcreteMutableSet.j index c5e3f9c91..59a460be0 100644 --- a/Foundation/CPSet/_CPConcreteMutableSet.j +++ b/Foundation/CPSet/_CPConcreteMutableSet.j @@ -92,7 +92,7 @@ var hasOwnProperty = Object.prototype.hasOwnProperty; */ - (void)addObject:(id)anObject { - if (anObject === nil || anObject === undefined) + if (anObject == nil) [CPException raise:CPInvalidArgumentException reason:@"attempt to insert nil or undefined"]; if ([self containsObject:anObject]) @@ -109,14 +109,14 @@ var hasOwnProperty = Object.prototype.hasOwnProperty; - (void)removeObject:(id)anObject { // Removing nil is an error. - if (anObject === nil || anObject === undefined) + if (anObject == nil) [CPException raise:CPInvalidArgumentException reason:@"attempt to remove nil or undefined"]; // anObject might be isEqual: another object in the set. We need the exact instance so we can remove it by UID. var object = [self member:anObject]; // ...but removing an object not present in the set is not an error. - if (object !== nil) + if (object != nil) { delete _contents[[object UID]]; _count--; diff --git a/Foundation/CPSet/_CPSet.j b/Foundation/CPSet/_CPSet.j index 7f92ded22..92cb37f7f 100644 --- a/Foundation/CPSet/_CPSet.j +++ b/Foundation/CPSet/_CPSet.j @@ -224,7 +224,7 @@ object, objectEnumerator = [self objectEnumerator]; - while ((object = [objectEnumerator nextObject]) !== nil) + while ((object = [objectEnumerator nextObject]) != nil) objects.push(object); return objects; @@ -244,7 +244,7 @@ */ - (BOOL)containsObject:(id)anObject { - return [self member:anObject] !== nil; + return [self member:anObject] != nil; } /*! @@ -257,7 +257,7 @@ object, objectEnumerator = [self objectEnumerator]; - while ((object = [objectEnumerator nextObject]) !== nil) + while ((object = [objectEnumerator nextObject]) != nil) if ([aPredicate evaluateWithObject:object]) objects.push(object); @@ -294,7 +294,7 @@ objectEnumerator = [self objectEnumerator], argumentsArray = [nil, aSelector].concat(objects || []); - while ((object = [objectEnumerator nextObject]) !== nil) + while ((object = [objectEnumerator nextObject]) != nil) { argumentsArray[0] = object; objj_msgSend.apply(this, argumentsArray); @@ -342,7 +342,7 @@ object = nil, objectEnumerator = [self objectEnumerator]; - while ((object = [objectEnumerator nextObject]) !== nil) + while ((object = [objectEnumerator nextObject]) != nil) if (aFunction(object)) objects.push(object); @@ -358,7 +358,7 @@ var object = nil, objectEnumerator = [self objectEnumerator]; - while ((object = [objectEnumerator nextObject]) !== nil) + while ((object = [objectEnumerator nextObject]) != nil) if (![aSet containsObject:object]) return NO; @@ -378,7 +378,7 @@ var object = nil, objectEnumerator = [self objectEnumerator]; - while ((object = [objectEnumerator nextObject]) !== nil) + while ((object = [objectEnumerator nextObject]) != nil) if ([aSet containsObject:object]) return YES; @@ -477,7 +477,7 @@ var CPSetObjectsKey = @"CPSetObjectsKey"; object, objectEnumerator = [self objectEnumerator]; - while ((object = [objectEnumerator nextObject]) !== nil) + while ((object = [objectEnumerator nextObject]) != nil) { var value = [object valueForKey:aKey]; @@ -492,7 +492,7 @@ var CPSetObjectsKey = @"CPSetObjectsKey"; var object, objectEnumerator = [self objectEnumerator]; - while ((object = [objectEnumerator nextObject]) !== nil) + while ((object = [objectEnumerator nextObject]) != nil) [object setValue:aValue forKey:aKey]; } diff --git a/Foundation/CPString.j b/Foundation/CPString.j index d87c4efd8..e9331e000 100644 --- a/Foundation/CPString.j +++ b/Foundation/CPString.j @@ -515,7 +515,7 @@ var CPStringNull = [CPNull null]; */ - (CPComparisonResult)compare:(CPString)aString options:(int)aMask { - if (aString === nil) + if (aString == nil) return CPOrderedDescending; if (aString === CPStringNull) diff --git a/Foundation/CPURLConnection.j b/Foundation/CPURLConnection.j index 52df11606..94738193f 100644 --- a/Foundation/CPURLConnection.j +++ b/Foundation/CPURLConnection.j @@ -125,7 +125,7 @@ var CPURLConnectionDelegate = nil; key = nil, keys = [fields keyEnumerator]; - while ((key = [keys nextObject]) !== nil) + while ((key = [keys nextObject]) != nil) aCFHTTPRequest.setRequestHeader(key, [fields objectForKey:key]); aCFHTTPRequest.send([aRequest HTTPBody]); @@ -259,7 +259,7 @@ var CPURLConnectionDelegate = nil; key = nil, keys = [fields keyEnumerator]; - while ((key = [keys nextObject]) !== nil) + while ((key = [keys nextObject]) != nil) _HTTPRequest.setRequestHeader(key, [fields objectForKey:key]); _HTTPRequest.send([_request HTTPBody]); @@ -274,7 +274,7 @@ var CPURLConnectionDelegate = nil; { if ([_delegate respondsToSelector:@selector(connection:didFailWithError:)]) [_delegate connection:self didFailWithError:anException]; - else if (_connectionOperation !== nil) + else if (_connectionOperation != nil) [self _connectionOperationDidReceiveResponse:nil data:nil error:anException]; } @@ -344,7 +344,7 @@ var CPURLConnectionDelegate = nil; { if ([_delegate respondsToSelector:@selector(connection:didReceiveData:)]) [_delegate connection:self didReceiveData:_HTTPRequest.responseText()]; - else if (_connectionOperation !== nil) + else if (_connectionOperation != nil) [self _connectionOperationDidReceiveResponse:response data:_HTTPRequest.responseText() error:nil]; if ([_delegate respondsToSelector:@selector(connectionDidFinishLoading:)]) diff --git a/Foundation/CPUndoManager.j b/Foundation/CPUndoManager.j index d4ad4914e..cfcc54b21 100644 --- a/Foundation/CPUndoManager.j +++ b/Foundation/CPUndoManager.j @@ -657,7 +657,7 @@ if (_currentGroup == nil) */ - (void)setActionName:(CPString)anActionName { - if (anActionName !== nil && _currentGrouping) + if (anActionName != nil && _currentGrouping) [_currentGrouping setActionName:anActionName]; } @@ -827,7 +827,7 @@ if (_currentGroup == nil) // Don't add no-ops to the undo stack. var before = [aChange valueForKey:CPKeyValueChangeOldKey], after = [aChange valueForKey:CPKeyValueChangeNewKey]; - if (before === after || (before !== nil && before.isa && (after === nil || after.isa) && [before isEqual:after])) + if (before === after || (before != nil && before.isa && (after == nil || after.isa) && [before isEqual:after])) return; [[self prepareWithInvocationTarget:anObject] diff --git a/Foundation/CPUserDefaults.j b/Foundation/CPUserDefaults.j index 278ba4603..8bc23bcf3 100644 --- a/Foundation/CPUserDefaults.j +++ b/Foundation/CPUserDefaults.j @@ -342,7 +342,7 @@ var StandardUserDefaults; var data = [[self persistentStoreForDomain:aDomain] data], domain = data ? [CPKeyedUnarchiver unarchiveObjectWithData:data] : nil; - if (domain === nil) + if (domain == nil) [_domains removeObjectForKey:aDomain]; else [_domains setObject:domain forKey:aDomain]; @@ -438,7 +438,7 @@ var StandardUserDefaults; - (float)floatForKey:(CPString)aKey { var value = [self objectForKey:aKey]; - if (value === nil) + if (value == nil) return 0; if ([value respondsToSelector:@selector(floatValue)]) @@ -453,7 +453,7 @@ var StandardUserDefaults; - (int)integerForKey:(CPString)aKey { var value = [self objectForKey:aKey]; - if (value === nil) + if (value == nil) return 0; if ([value respondsToSelector:@selector(intValue)]) diff --git a/Foundation/CPValueTransformer.j b/Foundation/CPValueTransformer.j index f8fb3d187..31f893511 100644 --- a/Foundation/CPValueTransformer.j +++ b/Foundation/CPValueTransformer.j @@ -135,7 +135,7 @@ var transformerMap = @{}; - (id)transformedValue:(id)aValue { - return aValue === nil || aValue === undefined; + return aValue == nil; } @end @@ -156,7 +156,7 @@ var transformerMap = @{}; - (id)transformedValue:(id)aValue { - return aValue !== nil && aValue !== undefined; + return aValue != nil; } @end diff --git a/Foundation/CPWebDAVManager.j b/Foundation/CPWebDAVManager.j index 1e2c11177..b761d4eea 100644 --- a/Foundation/CPWebDAVManager.j +++ b/Foundation/CPWebDAVManager.j @@ -45,7 +45,7 @@ var setURLResourceValuesForKeysFromProperties = function(aURL, keys, properties) var displayName = [properties objectForKey:@"displayname"]; - if (displayName !== nil) + if (displayName != nil) { [aURL setResourceValue:displayName forKey:CPURLNameKey]; [aURL setResourceValue:displayName forKey:CPURLLocalizedNameKey]; @@ -84,7 +84,7 @@ CPWebDAVManagerNonCollectionResourceType = 0; URLString = nil, URLStrings = [response keyEnumerator]; - while ((URLString = [URLStrings nextObject]) !== nil) + while ((URLString = [URLStrings nextObject]) != nil) { var URL = [CPURL URLWithString:URLString], properties = [response objectForKey:URLString]; diff --git a/Foundation/_CPCollectionKVCOperators.j b/Foundation/_CPCollectionKVCOperators.j index 36fe72145..8c7b68c9f 100644 --- a/Foundation/_CPCollectionKVCOperators.j +++ b/Foundation/_CPCollectionKVCOperators.j @@ -52,7 +52,7 @@ var _CPCollectionKVCOperatorSimpleRE = new RegExp("^@(avg|count|m(ax|in)|sum|uni enumerator = [objects objectEnumerator], object; - while ((object = [enumerator nextObject]) !== nil) + while ((object = [enumerator nextObject]) != nil) average += [object doubleValue]; return average / [objects count]; @@ -72,7 +72,7 @@ var _CPCollectionKVCOperatorSimpleRE = new RegExp("^@(avg|count|m(ax|in)|sum|uni min = [enumerator nextObject], object; - while ((object = [enumerator nextObject]) !== nil) + while ((object = [enumerator nextObject]) != nil) { if ([min compare:object] > 0) min = object; @@ -95,7 +95,7 @@ var _CPCollectionKVCOperatorSimpleRE = new RegExp("^@(avg|count|m(ax|in)|sum|uni max = [enumerator nextObject], object; - while ((object = [enumerator nextObject]) !== nil) + while ((object = [enumerator nextObject]) != nil) { if ([max compare:object] < 0) max = object; @@ -114,7 +114,7 @@ var _CPCollectionKVCOperatorSimpleRE = new RegExp("^@(avg|count|m(ax|in)|sum|uni enumerator = [objects objectEnumerator], object; - while ((object = [enumerator nextObject]) !== nil) + while ((object = [enumerator nextObject]) != nil) sum += [object doubleValue]; return sum; @@ -148,7 +148,7 @@ var _CPCollectionKVCOperatorSimpleRE = new RegExp("^@(avg|count|m(ax|in)|sum|uni enumerator = [objects objectEnumerator], object; - while ((object = [enumerator nextObject]) !== nil) + while ((object = [enumerator nextObject]) != nil) { if ([distinctObjects indexOfObject:object] == CPNotFound) [distinctObjects addObject:object]; @@ -186,7 +186,7 @@ var _CPCollectionKVCOperatorSimpleRE = new RegExp("^@(avg|count|m(ax|in)|sum|uni enumerator = [objects objectEnumerator], object; - while ((object = [enumerator nextObject]) !== nil) + while ((object = [enumerator nextObject]) != nil) { if ([distinctObjects indexOfObject:object] == CPNotFound) [distinctObjects addObject:object]; diff --git a/Objective-J/CFDictionary.js b/Objective-J/CFDictionary.js index 99fd02fb4..c3ff941ae 100644 --- a/Objective-J/CFDictionary.js +++ b/Objective-J/CFDictionary.js @@ -229,7 +229,7 @@ DISPLAY_NAME(CFMutableDictionary.prototype.replaceValueForKey); CFMutableDictionary.prototype.setValueForKey = function(/*String*/ aKey, /*Object*/ aValue) { - if (aValue === nil || aValue === undefined) + if (aValue == nil) this.removeValueForKey(aKey); else if (this.containsKey(aKey)) diff --git a/Tests/AppKit/CPNotificationCenterHelper.j b/Tests/AppKit/CPNotificationCenterHelper.j index 69aaed26c..7f8ad040c 100644 --- a/Tests/AppKit/CPNotificationCenterHelper.j +++ b/Tests/AppKit/CPNotificationCenterHelper.j @@ -11,7 +11,7 @@ notifications = [], name; - while ((name = [names nextObject]) !== nil) + while ((name = [names nextObject]) != nil) { var notificationRegistry = [defaultCenter._namedRegistries objectForKey:name], objectObservers = notificationRegistry._objectObservers, @@ -19,13 +19,13 @@ key; // Iterate through every set of observers - while ((key = [keys nextObject]) !== nil) + while ((key = [keys nextObject]) != nil) { var observers = [objectObservers objectForKey:key], observer = nil, observersEnumerator = [observers objectEnumerator]; - while ((observer = [observersEnumerator nextObject]) !== nil) + while ((observer = [observersEnumerator nextObject]) != nil) { if ([observer observer] == anObserver) [notifications addObject:name];