Skip to content

Commit df52c85

Browse files
committed
Fix silent option does not silence warnings about unknown options Choices-js#1119
1 parent 1b927a3 commit df52c85

21 files changed

+180
-149
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Bug Fixes (from 10.2.0)
66
* Fix Choices does not accept an element from an iframe [#1057](https://github.com/Choices-js/Choices/issues/1057)
77
* Fix Choices was not disable in a `<fieldset disabled>` [#1132](https://github.com/Choices-js/Choices/issues/1132)
8+
* Fix `silent` option does not silence warnings about unknown options [#1119](https://github.com/Choices-js/Choices/issues/1119)
89

910
## [11.0.0-rc5] (2024-08-08)
1011

public/assets/scripts/choices.cjs

+16-13
Original file line numberDiff line numberDiff line change
@@ -3646,19 +3646,8 @@ var Choices = /** @class */ (function () {
36463646
ObjectsInConfig.forEach(function (key) {
36473647
_this.config[key] = __assign(__assign(__assign({}, Choices.defaults.allOptions[key]), Choices.defaults.options[key]), userConfig[key]);
36483648
});
3649-
var invalidConfigOptions = diff(this.config, DEFAULT_CONFIG);
3650-
if (invalidConfigOptions.length) {
3651-
console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', '));
3652-
}
3653-
if (!this.config.silent &&
3654-
this.config.allowHTML &&
3655-
this.config.allowHtmlUserInput) {
3656-
if (this.config.addItems) {
3657-
console.warn('Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks');
3658-
}
3659-
if (this.config.addChoices) {
3660-
console.warn('Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks');
3661-
}
3649+
if (!this.config.silent) {
3650+
this._validateConfig();
36623651
}
36633652
var documentElement = this.config.shadowRoot || document.documentElement;
36643653
var passedElement = typeof element === 'string'
@@ -4236,6 +4225,20 @@ var Choices = /** @class */ (function () {
42364225
}
42374226
return this;
42384227
};
4228+
Choices.prototype._validateConfig = function () {
4229+
var invalidConfigOptions = diff(this.config, DEFAULT_CONFIG);
4230+
if (invalidConfigOptions.length) {
4231+
console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', '));
4232+
}
4233+
if (this.config.allowHTML && this.config.allowHtmlUserInput) {
4234+
if (this.config.addItems) {
4235+
console.warn('Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks');
4236+
}
4237+
if (this.config.addChoices) {
4238+
console.warn('Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks');
4239+
}
4240+
}
4241+
};
42394242
Choices.prototype._render = function () {
42404243
if (this._store.isLoading()) {
42414244
return;

public/assets/scripts/choices.js

+16-13
Original file line numberDiff line numberDiff line change
@@ -3650,19 +3650,8 @@
36503650
ObjectsInConfig.forEach(function (key) {
36513651
_this.config[key] = __assign(__assign(__assign({}, Choices.defaults.allOptions[key]), Choices.defaults.options[key]), userConfig[key]);
36523652
});
3653-
var invalidConfigOptions = diff(this.config, DEFAULT_CONFIG);
3654-
if (invalidConfigOptions.length) {
3655-
console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', '));
3656-
}
3657-
if (!this.config.silent &&
3658-
this.config.allowHTML &&
3659-
this.config.allowHtmlUserInput) {
3660-
if (this.config.addItems) {
3661-
console.warn('Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks');
3662-
}
3663-
if (this.config.addChoices) {
3664-
console.warn('Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks');
3665-
}
3653+
if (!this.config.silent) {
3654+
this._validateConfig();
36663655
}
36673656
var documentElement = this.config.shadowRoot || document.documentElement;
36683657
var passedElement = typeof element === 'string'
@@ -4240,6 +4229,20 @@
42404229
}
42414230
return this;
42424231
};
4232+
Choices.prototype._validateConfig = function () {
4233+
var invalidConfigOptions = diff(this.config, DEFAULT_CONFIG);
4234+
if (invalidConfigOptions.length) {
4235+
console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', '));
4236+
}
4237+
if (this.config.allowHTML && this.config.allowHtmlUserInput) {
4238+
if (this.config.addItems) {
4239+
console.warn('Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks');
4240+
}
4241+
if (this.config.addChoices) {
4242+
console.warn('Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks');
4243+
}
4244+
}
4245+
};
42434246
Choices.prototype._render = function () {
42444247
if (this._store.isLoading()) {
42454248
return;

public/assets/scripts/choices.min.cjs

+1-1
Large diffs are not rendered by default.

public/assets/scripts/choices.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/assets/scripts/choices.min.mjs

+1-1
Large diffs are not rendered by default.

public/assets/scripts/choices.mjs

+16-13
Original file line numberDiff line numberDiff line change
@@ -3644,19 +3644,8 @@ var Choices = /** @class */ (function () {
36443644
ObjectsInConfig.forEach(function (key) {
36453645
_this.config[key] = __assign(__assign(__assign({}, Choices.defaults.allOptions[key]), Choices.defaults.options[key]), userConfig[key]);
36463646
});
3647-
var invalidConfigOptions = diff(this.config, DEFAULT_CONFIG);
3648-
if (invalidConfigOptions.length) {
3649-
console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', '));
3650-
}
3651-
if (!this.config.silent &&
3652-
this.config.allowHTML &&
3653-
this.config.allowHtmlUserInput) {
3654-
if (this.config.addItems) {
3655-
console.warn('Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks');
3656-
}
3657-
if (this.config.addChoices) {
3658-
console.warn('Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks');
3659-
}
3647+
if (!this.config.silent) {
3648+
this._validateConfig();
36603649
}
36613650
var documentElement = this.config.shadowRoot || document.documentElement;
36623651
var passedElement = typeof element === 'string'
@@ -4234,6 +4223,20 @@ var Choices = /** @class */ (function () {
42344223
}
42354224
return this;
42364225
};
4226+
Choices.prototype._validateConfig = function () {
4227+
var invalidConfigOptions = diff(this.config, DEFAULT_CONFIG);
4228+
if (invalidConfigOptions.length) {
4229+
console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', '));
4230+
}
4231+
if (this.config.allowHTML && this.config.allowHtmlUserInput) {
4232+
if (this.config.addItems) {
4233+
console.warn('Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks');
4234+
}
4235+
if (this.config.addChoices) {
4236+
console.warn('Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks');
4237+
}
4238+
}
4239+
};
42374240
Choices.prototype._render = function () {
42384241
if (this._store.isLoading()) {
42394242
return;

public/assets/scripts/choices.search-basic.cjs

+16-13
Original file line numberDiff line numberDiff line change
@@ -3164,19 +3164,8 @@ var Choices = /** @class */ (function () {
31643164
ObjectsInConfig.forEach(function (key) {
31653165
_this.config[key] = __assign(__assign(__assign({}, Choices.defaults.allOptions[key]), Choices.defaults.options[key]), userConfig[key]);
31663166
});
3167-
var invalidConfigOptions = diff(this.config, DEFAULT_CONFIG);
3168-
if (invalidConfigOptions.length) {
3169-
console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', '));
3170-
}
3171-
if (!this.config.silent &&
3172-
this.config.allowHTML &&
3173-
this.config.allowHtmlUserInput) {
3174-
if (this.config.addItems) {
3175-
console.warn('Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks');
3176-
}
3177-
if (this.config.addChoices) {
3178-
console.warn('Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks');
3179-
}
3167+
if (!this.config.silent) {
3168+
this._validateConfig();
31803169
}
31813170
var documentElement = this.config.shadowRoot || document.documentElement;
31823171
var passedElement = typeof element === 'string'
@@ -3754,6 +3743,20 @@ var Choices = /** @class */ (function () {
37543743
}
37553744
return this;
37563745
};
3746+
Choices.prototype._validateConfig = function () {
3747+
var invalidConfigOptions = diff(this.config, DEFAULT_CONFIG);
3748+
if (invalidConfigOptions.length) {
3749+
console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', '));
3750+
}
3751+
if (this.config.allowHTML && this.config.allowHtmlUserInput) {
3752+
if (this.config.addItems) {
3753+
console.warn('Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks');
3754+
}
3755+
if (this.config.addChoices) {
3756+
console.warn('Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks');
3757+
}
3758+
}
3759+
};
37573760
Choices.prototype._render = function () {
37583761
if (this._store.isLoading()) {
37593762
return;

public/assets/scripts/choices.search-basic.js

+16-13
Original file line numberDiff line numberDiff line change
@@ -3168,19 +3168,8 @@
31683168
ObjectsInConfig.forEach(function (key) {
31693169
_this.config[key] = __assign(__assign(__assign({}, Choices.defaults.allOptions[key]), Choices.defaults.options[key]), userConfig[key]);
31703170
});
3171-
var invalidConfigOptions = diff(this.config, DEFAULT_CONFIG);
3172-
if (invalidConfigOptions.length) {
3173-
console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', '));
3174-
}
3175-
if (!this.config.silent &&
3176-
this.config.allowHTML &&
3177-
this.config.allowHtmlUserInput) {
3178-
if (this.config.addItems) {
3179-
console.warn('Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks');
3180-
}
3181-
if (this.config.addChoices) {
3182-
console.warn('Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks');
3183-
}
3171+
if (!this.config.silent) {
3172+
this._validateConfig();
31843173
}
31853174
var documentElement = this.config.shadowRoot || document.documentElement;
31863175
var passedElement = typeof element === 'string'
@@ -3758,6 +3747,20 @@
37583747
}
37593748
return this;
37603749
};
3750+
Choices.prototype._validateConfig = function () {
3751+
var invalidConfigOptions = diff(this.config, DEFAULT_CONFIG);
3752+
if (invalidConfigOptions.length) {
3753+
console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', '));
3754+
}
3755+
if (this.config.allowHTML && this.config.allowHtmlUserInput) {
3756+
if (this.config.addItems) {
3757+
console.warn('Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks');
3758+
}
3759+
if (this.config.addChoices) {
3760+
console.warn('Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks');
3761+
}
3762+
}
3763+
};
37613764
Choices.prototype._render = function () {
37623765
if (this._store.isLoading()) {
37633766
return;

public/assets/scripts/choices.search-basic.min.cjs

+1-1
Large diffs are not rendered by default.

public/assets/scripts/choices.search-basic.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/assets/scripts/choices.search-basic.min.mjs

+1-1
Large diffs are not rendered by default.

public/assets/scripts/choices.search-basic.mjs

+16-13
Original file line numberDiff line numberDiff line change
@@ -3162,19 +3162,8 @@ var Choices = /** @class */ (function () {
31623162
ObjectsInConfig.forEach(function (key) {
31633163
_this.config[key] = __assign(__assign(__assign({}, Choices.defaults.allOptions[key]), Choices.defaults.options[key]), userConfig[key]);
31643164
});
3165-
var invalidConfigOptions = diff(this.config, DEFAULT_CONFIG);
3166-
if (invalidConfigOptions.length) {
3167-
console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', '));
3168-
}
3169-
if (!this.config.silent &&
3170-
this.config.allowHTML &&
3171-
this.config.allowHtmlUserInput) {
3172-
if (this.config.addItems) {
3173-
console.warn('Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks');
3174-
}
3175-
if (this.config.addChoices) {
3176-
console.warn('Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks');
3177-
}
3165+
if (!this.config.silent) {
3166+
this._validateConfig();
31783167
}
31793168
var documentElement = this.config.shadowRoot || document.documentElement;
31803169
var passedElement = typeof element === 'string'
@@ -3752,6 +3741,20 @@ var Choices = /** @class */ (function () {
37523741
}
37533742
return this;
37543743
};
3744+
Choices.prototype._validateConfig = function () {
3745+
var invalidConfigOptions = diff(this.config, DEFAULT_CONFIG);
3746+
if (invalidConfigOptions.length) {
3747+
console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', '));
3748+
}
3749+
if (this.config.allowHTML && this.config.allowHtmlUserInput) {
3750+
if (this.config.addItems) {
3751+
console.warn('Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks');
3752+
}
3753+
if (this.config.addChoices) {
3754+
console.warn('Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks');
3755+
}
3756+
}
3757+
};
37553758
Choices.prototype._render = function () {
37563759
if (this._store.isLoading()) {
37573760
return;

public/assets/scripts/choices.search-prefix.cjs

+16-13
Original file line numberDiff line numberDiff line change
@@ -2030,19 +2030,8 @@ var Choices = /** @class */ (function () {
20302030
ObjectsInConfig.forEach(function (key) {
20312031
_this.config[key] = __assign(__assign(__assign({}, Choices.defaults.allOptions[key]), Choices.defaults.options[key]), userConfig[key]);
20322032
});
2033-
var invalidConfigOptions = diff(this.config, DEFAULT_CONFIG);
2034-
if (invalidConfigOptions.length) {
2035-
console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', '));
2036-
}
2037-
if (!this.config.silent &&
2038-
this.config.allowHTML &&
2039-
this.config.allowHtmlUserInput) {
2040-
if (this.config.addItems) {
2041-
console.warn('Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks');
2042-
}
2043-
if (this.config.addChoices) {
2044-
console.warn('Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks');
2045-
}
2033+
if (!this.config.silent) {
2034+
this._validateConfig();
20462035
}
20472036
var documentElement = this.config.shadowRoot || document.documentElement;
20482037
var passedElement = typeof element === 'string'
@@ -2620,6 +2609,20 @@ var Choices = /** @class */ (function () {
26202609
}
26212610
return this;
26222611
};
2612+
Choices.prototype._validateConfig = function () {
2613+
var invalidConfigOptions = diff(this.config, DEFAULT_CONFIG);
2614+
if (invalidConfigOptions.length) {
2615+
console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', '));
2616+
}
2617+
if (this.config.allowHTML && this.config.allowHtmlUserInput) {
2618+
if (this.config.addItems) {
2619+
console.warn('Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks');
2620+
}
2621+
if (this.config.addChoices) {
2622+
console.warn('Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks');
2623+
}
2624+
}
2625+
};
26232626
Choices.prototype._render = function () {
26242627
if (this._store.isLoading()) {
26252628
return;

public/assets/scripts/choices.search-prefix.js

+16-13
Original file line numberDiff line numberDiff line change
@@ -2034,19 +2034,8 @@
20342034
ObjectsInConfig.forEach(function (key) {
20352035
_this.config[key] = __assign(__assign(__assign({}, Choices.defaults.allOptions[key]), Choices.defaults.options[key]), userConfig[key]);
20362036
});
2037-
var invalidConfigOptions = diff(this.config, DEFAULT_CONFIG);
2038-
if (invalidConfigOptions.length) {
2039-
console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', '));
2040-
}
2041-
if (!this.config.silent &&
2042-
this.config.allowHTML &&
2043-
this.config.allowHtmlUserInput) {
2044-
if (this.config.addItems) {
2045-
console.warn('Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks');
2046-
}
2047-
if (this.config.addChoices) {
2048-
console.warn('Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks');
2049-
}
2037+
if (!this.config.silent) {
2038+
this._validateConfig();
20502039
}
20512040
var documentElement = this.config.shadowRoot || document.documentElement;
20522041
var passedElement = typeof element === 'string'
@@ -2624,6 +2613,20 @@
26242613
}
26252614
return this;
26262615
};
2616+
Choices.prototype._validateConfig = function () {
2617+
var invalidConfigOptions = diff(this.config, DEFAULT_CONFIG);
2618+
if (invalidConfigOptions.length) {
2619+
console.warn('Unknown config option(s) passed', invalidConfigOptions.join(', '));
2620+
}
2621+
if (this.config.allowHTML && this.config.allowHtmlUserInput) {
2622+
if (this.config.addItems) {
2623+
console.warn('Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks');
2624+
}
2625+
if (this.config.addChoices) {
2626+
console.warn('Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks');
2627+
}
2628+
}
2629+
};
26272630
Choices.prototype._render = function () {
26282631
if (this._store.isLoading()) {
26292632
return;

public/assets/scripts/choices.search-prefix.min.cjs

+1-1
Large diffs are not rendered by default.

public/assets/scripts/choices.search-prefix.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/assets/scripts/choices.search-prefix.min.mjs

+1-1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)