Skip to content

Commit

Permalink
Merge pull request #209 from mavenlink/start-removing-jquery
Browse files Browse the repository at this point in the history
Prefer Object.assign to $.extend to merge objects
  • Loading branch information
guanw88 authored Mar 7, 2024
2 parents b83bc93 + 81d5f44 commit cf8af80
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion spec/helpers/builders.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec.defineBuilders = ->

factory = BackboneFactory.define(name, klass, -> return class_defaults)
builder = (opts) ->
BackboneFactory.create(name, $.extend({}, class_defaults, idsToStrings(opts)))
BackboneFactory.create(name, Object.assign({}, class_defaults, idsToStrings(opts)))

creator = (opts) ->
storageManager = StorageManager.get()
Expand Down
14 changes: 6 additions & 8 deletions src/storage-manager.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
_ = require 'underscore'
$ = require 'jquery'
Backbone = require 'backbone'
Backbone.$ = $ # TODO remove after upgrading to backbone 1.2+
inflection = require 'inflection'

Utils = require './utils'
Expand Down Expand Up @@ -92,7 +90,7 @@ class _StorageManager
loadModel: (name, id, options = {}) ->
return if not id

loader = @loadObject(name, $.extend({}, options, only: id), isCollection: false)
loader = @loadObject(name, Object.assign({}, options, only: id), isCollection: false)
loader

# Request a set of data to be loaded, optionally ensuring that associations be
Expand All @@ -113,14 +111,14 @@ class _StorageManager

# Helpers
loadObject: (name, loadOptions = {}, options = {}) ->
options = $.extend({}, { isCollection: true }, options)
options = Object.assign({}, { isCollection: true }, options)

completeCallback = loadOptions.complete
successCallback = loadOptions.success
errorCallback = loadOptions.error

loadOptions = _.omit(loadOptions, 'success', 'error', 'complete')
loadOptions = $.extend({}, loadOptions, name: name)
loadOptions = Object.assign({}, loadOptions, name: name)

if options.isCollection
loaderClass = CollectionLoader
Expand Down Expand Up @@ -155,7 +153,7 @@ class _StorageManager
# brainstem AJAX response. Useful in avoiding unnecessary AJAX request(s) when rendering the page.
bootstrap: (name, response, loadOptions = {}) ->
loader = new CollectionLoader storageManager: this
loader.setup $.extend({}, loadOptions, name: name)
loader.setup Object.assign({}, loadOptions, name: name)
loader._updateStorageManagerFromResponse response

collectionError: (name) ->
Expand All @@ -179,10 +177,10 @@ class _StorageManager
')

stubModel: (modelName, modelId, options = {}) ->
@stub(inflection.pluralize(modelName), $.extend({}, options, only: modelId))
@stub(inflection.pluralize(modelName), Object.assign({}, options, only: modelId))

stubImmediate: (collectionName, options) ->
@stub collectionName, $.extend({}, options, immediate: true)
@stub collectionName, Object.assign({}, options, immediate: true)

enableExpectations: ->
@expectations = []
Expand Down

0 comments on commit cf8af80

Please sign in to comment.