Skip to content

Commit

Permalink
Fix name collision. Do not rely on Object.assign.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Perez committed Mar 9, 2016
1 parent 0bfefb4 commit 2297513
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 213 deletions.
378 changes: 181 additions & 197 deletions dist/riot-form.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/riot-form.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/riot-form.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/riot-form.min.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions lib/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {capitalize} from './util'
import assign from 'object-assign'

const defaultConfig = {
formatErrors: (errors) => {
Expand All @@ -25,10 +26,10 @@ const defaultConfig = {
inputContainerClassName: ''
}

const config = Object.assign({}, defaultConfig)
const config = assign({}, defaultConfig)

export function restore() {
Object.assign(config, defaultConfig)
assign(config, defaultConfig)
}

export {defaultConfig as defaultConfig}
Expand Down
3 changes: 2 additions & 1 deletion lib/form-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import assert from 'assert'
import Form from './form'
import BaseInput from './inputs/base'
import inputFactory from './input-factory'
import assign from 'object-assign'

export default class FormBuilder {
constructor(name) {
Expand Down Expand Up @@ -34,7 +35,7 @@ export default class FormBuilder {
}

build(config = {}) {
return new Form(Object.assign({
return new Form(assign({
model: this._model,
inputs: this._inputs,
name: this._name
Expand Down
5 changes: 3 additions & 2 deletions lib/form.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import riot from 'riot'
import riot from 'riot'
import assert from 'assert'
import assign from 'object-assign'

export default class Form {
constructor(config = {}) {
Expand Down Expand Up @@ -35,7 +36,7 @@ export default class Form {
if (this.config.noClone) {
this._model = model
} else {
this._model = Object.assign({}, model)
this._model = assign({}, model)
}
this._setInputValues()
}
Expand Down
4 changes: 3 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import assign from 'object-assign'

import config from './config'
import Form from './form'
import FormBuilder from './form-builder'
Expand All @@ -12,7 +14,7 @@ for (const input of Object.keys(inputs)) {
}

export function configure(conf) {
Object.assign(config, conf)
assign(config, conf)
}

export {Form as Form}
Expand Down
13 changes: 7 additions & 6 deletions lib/inputs/base.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import assert from 'assert'
import riot from 'riot'
import config from '../config'
import assert from 'assert'
import riot from 'riot'
import assign from 'object-assign'
import globalConfig from '../config'

export default class BaseInput {
constructor(config = {}) {
Expand Down Expand Up @@ -88,16 +89,16 @@ export default class BaseInput {
}

get defaultProcess() {
return config.processValue
return globalConfig.processValue
}

get defaultFormatErrors() {
return config.formatErrors
return globalConfig.formatErrors
}
}

BaseInput.extend = function (props) {
class Input extends BaseInput {}
Object.assign(Input.prototype, props)
assign(Input.prototype, props)
return Input
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,8 @@
"webdriverio": "^4.0.3",
"webpack": "^1.12.14",
"webpack-stream": "^3.1.0"
},
"dependencies": {
"object-assign": "^4.0.1"
}
}

0 comments on commit 2297513

Please sign in to comment.