Fix DOMPurify sanitize TypeError in Library components

Vue 2's initMethods calls .bind(vm) on every method, which creates a new
function that loses custom properties. The DOMPurify default export is a
callable function with .sanitize() as a property, so binding it strips
sanitize entirely, causing "TypeError: e.purify.sanitize is not a function"
at runtime.

Move purify out of methods/data and into setup() which returns values to
the template without binding. Also fix an import ordering lint issue in
DataTables.vue.

Fixes #22239
This commit is contained in:
Dannon Baker
2026-03-25 21:09:08 -04:00
parent 5ad3bac893
commit ca4f3676f9
2 changed files with 6 additions and 4 deletions
@@ -60,13 +60,15 @@ export default {
type: Boolean,
},
},
setup() {
return { purify };
},
data() {
return {
maxDescriptionLength: MAX_DESCRIPTION_LENGTH,
};
},
methods: {
purify,
updateValue(value) {
this.$emit("update:changedValue", value);
},
@@ -330,6 +330,9 @@ export default {
required: false,
},
},
setup() {
return { purify };
},
data() {
return {
...initialFolderState(),
@@ -349,8 +352,6 @@ export default {
faTimes,
faUnlock,
faUsers,
// Utilities
purify,
// Data
currentPage: 1,
sortBy: "name",
@@ -396,7 +397,6 @@ export default {
this.getFolder(this.folder_id, this.page);
},
methods: {
purify,
getFolder(folder_id, page) {
this.currentFolderId = folder_id;
this.currentPage = page;