Skip to content

Commit

Permalink
fix: remove sanitize html for labels
Browse files Browse the repository at this point in the history
closes #174
  • Loading branch information
palcarazm committed May 17, 2024
1 parent 1303275 commit 803481c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
11 changes: 4 additions & 7 deletions js/bootstrap5-toggle.ecmas.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* @see https://github.com/palcarazm/bootstrap5-toggle/blob/master/LICENSE
*/


"use strict";
function sanitize(text) {
if (!text) return text; // handle null or undefined
Expand Down Expand Up @@ -69,7 +68,7 @@ function sanitize(text) {
// B: Set options
this.options = {
onlabel:
sanitize(this.element.getAttribute("data-onlabel")) ||
this.element.getAttribute("data-onlabel") ||
options.onlabel ||
DEPRECATION.value ||
DEFAULTS.onlabel,
Expand All @@ -88,7 +87,7 @@ function sanitize(text) {
sanitize(this.element.getAttribute("title")) ||
DEFAULTS.ontitle,
offlabel:
sanitize(this.element.getAttribute("data-offlabel")) ||
this.element.getAttribute("data-offlabel") ||
options.offlabel ||
DEPRECATION.value ||
DEFAULTS.offlabel,
Expand Down Expand Up @@ -139,7 +138,7 @@ function sanitize(text) {
if (this.options.onlabel === DEPRECATION.value) {
if (sanitize(this.element.getAttribute("data-on"))) {
DEPRECATION.log(DEPRECATION.ATTRIBUTE, "data-on", "data-onlabel");
this.options.onlabel = sanitize(this.element.getAttribute("data-on"));
this.options.onlabel = this.element.getAttribute("data-on");
} else if (options.on) {
DEPRECATION.log(DEPRECATION.OPTION, "on", "onlabel");
this.options.onlabel = options.on;
Expand All @@ -150,9 +149,7 @@ function sanitize(text) {
if (this.options.offlabel === DEPRECATION.value) {
if (sanitize(this.element.getAttribute("data-off"))) {
DEPRECATION.log(DEPRECATION.ATTRIBUTE, "data-off", "data-offlabel");
this.options.offlabel = sanitize(
this.element.getAttribute("data-off")
);
this.options.offlabel = this.element.getAttribute("data-off");
} else if (options.off) {
DEPRECATION.log(DEPRECATION.OPTION, "off", "offlabel");
this.options.offlabel = options.off;
Expand Down
9 changes: 4 additions & 5 deletions js/bootstrap5-toggle.jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* @see https://github.com/palcarazm/bootstrap5-toggle/blob/master/LICENSE
*/


"use strict";
function sanitize(text) {
if (!text) return text; // handle null or undefined
Expand Down Expand Up @@ -46,7 +45,7 @@ function sanitize(text) {
"data-on",
"data-onlabel"
);
this.options.onlabel = sanitize(this.$element.attr("data-on"));
this.options.onlabel = this.$element.attr("data-on");
} else if (options.on) {
Toggle.DEPRECATION.log(Toggle.DEPRECATION.OPTION, "on", "onlabel");
this.options.onlabel = options.on;
Expand All @@ -61,7 +60,7 @@ function sanitize(text) {
"data-off",
"data-offlabel"
);
this.options.offlabel = sanitize(this.$element.attr("data-off"));
this.options.offlabel = this.$element.attr("data-off");
} else if (options.off) {
Toggle.DEPRECATION.log(Toggle.DEPRECATION.OPTION, "off", "offlabel");
this.options.offlabel = options.off;
Expand Down Expand Up @@ -107,11 +106,11 @@ function sanitize(text) {
Toggle.prototype.defaults = function () {
return {
onlabel:
sanitize(this.$element.attr("data-onlabel")) ||
this.$element.attr("data-onlabel") ||
Toggle.DEPRECATION.value ||
Toggle.DEFAULTS.onlabel,
offlabel:
sanitize(this.$element.attr("data-offlabel")) ||
this.$element.attr("data-offlabel") ||
Toggle.DEPRECATION.value ||
Toggle.DEFAULTS.offlabel,
onstyle:
Expand Down

0 comments on commit 803481c

Please sign in to comment.