|
1 | 1 | /**
|
2 |
| - * vue-autonumeric v1.0.7 (https://github.com/autoNumeric/vue-autoNumeric) |
| 2 | + * vue-autonumeric v1.1.0 (https://github.com/autoNumeric/vue-autoNumeric) |
3 | 3 | * © 2018 Alexandre Bonneau <alexandre.bonneau@linuxfr.eu>
|
4 | 4 | * Released under the MIT License.
|
5 | 5 | */
|
@@ -393,6 +393,15 @@ exports.default = {
|
393 | 393 | },
|
394 | 394 |
|
395 | 395 |
|
| 396 | + computed: { |
| 397 | + anInfo: function anInfo() { |
| 398 | + return { |
| 399 | + value: this.value, |
| 400 | + options: this.options |
| 401 | + }; |
| 402 | + } |
| 403 | + }, |
| 404 | + |
396 | 405 | methods: {
|
397 | 406 | updateVModel: function updateVModel(event) {
|
398 | 407 | if (this.anElement !== null) {
|
@@ -422,29 +431,40 @@ exports.default = {
|
422 | 431 | },
|
423 | 432 |
|
424 | 433 | watch: {
|
425 |
| - value: function value(newValue, oldValue) { |
426 |
| - try { |
427 |
| - if (!this.userInteraction) { |
428 |
| - if (newValue !== oldValue) { |
429 |
| - this.anElement.set(newValue); |
| 434 | + anInfo: function anInfo(newValue, oldValue) { |
| 435 | + if (oldValue.options && (0, _stringify2.default)(newValue.options) !== (0, _stringify2.default)(oldValue.options)) { |
| 436 | + var optionsToUse = void 0; |
| 437 | + if (this.resetOnOptions) { |
| 438 | + if (Array.isArray(newValue.options)) { |
| 439 | + newValue.options = _AutoNumeric2.default.mergeOptions(newValue.options); |
430 | 440 | }
|
431 |
| - } |
432 |
| - } catch (error) { |
433 |
| - console.error(error); |
434 |
| - } |
435 | 441 |
|
436 |
| - this.resetUserInteraction(); |
437 |
| - }, |
438 |
| - options: function options(newValue, oldValue) { |
439 |
| - if ((0, _stringify2.default)(newValue) !== (0, _stringify2.default)(oldValue)) { |
440 |
| - if (this.resetOnOptions) { |
441 | 442 | var decimalPlacesRawValue = this.anElement.getSettings().decimalPlacesRawValue;
|
442 |
| - var optionsToReset = (0, _assign2.default)({}, _AutoNumeric2.default.getDefaultConfig(), { decimalPlacesRawValue: decimalPlacesRawValue }); |
| 443 | + var newOptions = _AutoNumeric2.default._getOptionObject(newValue.options); |
| 444 | + if (newOptions.decimalPlaces && newOptions.decimalPlaces > decimalPlacesRawValue) { |
| 445 | + optionsToUse = (0, _assign2.default)({}, _AutoNumeric2.default.getDefaultConfig(), newOptions); |
| 446 | + } else { |
| 447 | + optionsToUse = (0, _assign2.default)({}, _AutoNumeric2.default.getDefaultConfig(), { decimalPlacesRawValue: decimalPlacesRawValue }, newOptions); |
| 448 | + } |
| 449 | + } else { |
| 450 | + optionsToUse = newValue.options; |
| 451 | + } |
443 | 452 |
|
444 |
| - this.anElement.update(optionsToReset); |
| 453 | + this.anElement.update(optionsToUse); |
| 454 | + } |
| 455 | + |
| 456 | + if (newValue.value !== void 0) { |
| 457 | + try { |
| 458 | + if (!this.userInteraction) { |
| 459 | + if (newValue.value !== oldValue.value) { |
| 460 | + this.anElement.set(newValue.value); |
| 461 | + } |
| 462 | + } |
| 463 | + } catch (error) { |
| 464 | + console.error(error); |
445 | 465 | }
|
446 | 466 |
|
447 |
| - this.anElement.update(newValue); |
| 467 | + this.resetUserInteraction(); |
448 | 468 | }
|
449 | 469 | }
|
450 | 470 | }
|
|
0 commit comments