Skip to content

UCodeMirror: null values showing fixed

Ruslan Onyshchenko requested to merge fix/UCodeMirror_null_values_fix into master

In UCodeMirror in code:

  methods: {
    updateValue (newVal) {
      if (!this._codeMirror) return
      let newValAsText = typeof newVal === 'object' ? JSON.stringify(newVal, null, 2) : newVal
      if (newValAsText !== this.textValue) {
        this.textValue = newValAsText
        this._codeMirror.setValue(newValAsText)
      }
    },

in line let newValAsText = typeof newVal === 'object' ? JSON.stringify(newVal, null, 2) : newVal

If newVal will be null

typeof null === 'object' => true

so we have

JSON.stringify(null, null, 2)

and null value is shown instead of an empty string

Merge request reports

Loading