mirror of
https://github.com/Choices-js/Choices.git
synced 2024-06-08 00:42:15 +02:00
Avoid name conflict with stripHTML
This commit is contained in:
parent
9dbb2e9733
commit
67e1940232
|
@ -1,4 +1,4 @@
|
|||
import { calcWidthOfInput, escape } from '../lib/utils';
|
||||
import { calcWidthOfInput, stripHTML } from '../lib/utils';
|
||||
|
||||
export default class Input {
|
||||
constructor({ element, type, classNames, placeholderValue }) {
|
||||
|
@ -25,7 +25,7 @@ export default class Input {
|
|||
}
|
||||
|
||||
get value() {
|
||||
return escape(this.element.value);
|
||||
return stripHTML(this.element.value);
|
||||
}
|
||||
|
||||
addEventListeners() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { escape } from './lib/utils';
|
||||
import { stripHTML } from './lib/utils';
|
||||
|
||||
export const DEFAULT_CLASSNAMES = {
|
||||
containerOuter: 'choices',
|
||||
|
@ -63,7 +63,7 @@ export const DEFAULT_CONFIG = {
|
|||
noChoicesText: 'No choices to choose from',
|
||||
itemSelectText: 'Press to select',
|
||||
uniqueItemText: 'Only unique values can be added.',
|
||||
addItemText: value => `Press Enter to add <b>"${escape(value)}"</b>`,
|
||||
addItemText: value => `Press Enter to add <b>"${stripHTML(value)}"</b>`,
|
||||
maxItemText: maxItemCount => `Only ${maxItemCount} values can be added.`,
|
||||
itemComparer: (choice, item) => choice === item,
|
||||
fuseOptions: {
|
||||
|
|
|
@ -189,7 +189,7 @@ export const isScrolledIntoView = (el, parent, direction = 1) => {
|
|||
* @param {String} html Initial string/html
|
||||
* @return {String} Sanitised string
|
||||
*/
|
||||
export const escape = html =>
|
||||
export const stripHTML = html =>
|
||||
html.replace(/&/g, '&')
|
||||
.replace(/>/g, '&rt;')
|
||||
.replace(/</g, '<')
|
||||
|
@ -235,7 +235,7 @@ export const calcWidthOfInput = (input, callback) => {
|
|||
let width = input.offsetWidth;
|
||||
|
||||
if (value) {
|
||||
const testEl = strToEl(`<span>${escape(value)}</span>`);
|
||||
const testEl = strToEl(`<span>${stripHTML(value)}</span>`);
|
||||
testEl.style.position = 'absolute';
|
||||
testEl.style.padding = '0';
|
||||
testEl.style.top = '-9999px';
|
||||
|
|
Loading…
Reference in a new issue