A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/bootstrap-vue/bootstrap-vue/commit/0c57ffe31c946475498fa3554b8b4aba4e9d19df below:

handle nested form options normalization (#5247) · bootstrap-vue/bootstrap-vue@0c57ffe · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+19

-17

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+19

-17

lines changed Original file line number Diff line number Diff line change

@@ -1,5 +1,5 @@

1 1

import get from '../../../utils/get'

2 -

import { isArray, isPlainObject, isUndefined } from '../../../utils/inspect'

2 +

import { isNull, isPlainObject, isUndefined } from '../../../utils/inspect'

3 3

import formOptionsMixin from '../../../mixins/form-options'

4 4 5 5

// @vue/component

@@ -21,12 +21,12 @@ export default {

21 21

if (isPlainObject(option)) {

22 22

const value = get(option, this.valueField)

23 23

const text = get(option, this.textField)

24 -

const options = get(option, this.optionsField)

24 +

const options = get(option, this.optionsField, null)

25 25

// When it has options, create an `<optgroup>` object

26 -

if (isArray(options)) {

26 +

if (!isNull(options)) {

27 27

return {

28 28

label: String(get(option, this.labelField) || text),

29 -

options

29 +

options: this.normalizeOptions(options)

30 30

}

31 31

}

32 32

// Otherwise create an `<option>` object

Original file line number Diff line number Diff line change

@@ -33,19 +33,7 @@ export default {

33 33

},

34 34

computed: {

35 35

formOptions() {

36 -

const options = this.options

37 -

// Normalize the given options array

38 -

if (isArray(options)) {

39 -

return options.map(option => this.normalizeOption(option))

40 -

} else if (isPlainObject(options)) {

41 -

// Deprecate the object options format

42 -

warn(OPTIONS_OBJECT_DEPRECATED_MSG, this.$options.name)

43 -

// Normalize a `options` object to an array of options

44 -

return keys(options).map(key => this.normalizeOption(options[key] || {}, key))

45 -

}

46 -

// If not an array or object, return an empty array

47 -

/* istanbul ignore next */

48 -

return []

36 +

return this.normalizeOptions(this.options)

49 37

}

50 38

},

51 39

methods: {

@@ -67,6 +55,20 @@ export default {

67 55

text: stripTags(String(option)),

68 56

disabled: false

69 57

}

58 +

},

59 +

normalizeOptions(options) {

60 +

// Normalize the given options array

61 +

if (isArray(options)) {

62 +

return options.map(option => this.normalizeOption(option))

63 +

} else if (isPlainObject(options)) {

64 +

// Deprecate the object options format

65 +

warn(OPTIONS_OBJECT_DEPRECATED_MSG, this.$options.name)

66 +

// Normalize a `options` object to an array of options

67 +

return keys(options).map(key => this.normalizeOption(options[key] || {}, key))

68 +

}

69 +

// If not an array or object, return an empty array

70 +

/* istanbul ignore next */

71 +

return []

70 72

}

71 73

}

72 74

}

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4