mirror of
https://github.com/videojs/video.js.git
synced 2025-01-08 07:00:10 +02:00
fix(menu-item): update regex 'containsHexCode' function
This commit is contained in:
parent
a43965fd77
commit
26d9a10042
@ -4,6 +4,7 @@
|
|||||||
import ClickableComponent from '../clickable-component.js';
|
import ClickableComponent from '../clickable-component.js';
|
||||||
import Component from '../component.js';
|
import Component from '../component.js';
|
||||||
import {createEl} from '../utils/dom.js';
|
import {createEl} from '../utils/dom.js';
|
||||||
|
import { containsHexCode } from '../utils/str.js';
|
||||||
|
|
||||||
/** @import Player from '../player' */
|
/** @import Player from '../player' */
|
||||||
|
|
||||||
@ -74,10 +75,6 @@ class MenuItem extends ClickableComponent {
|
|||||||
textContent: this.localize(this.options_.label)
|
textContent: this.localize(this.options_.label)
|
||||||
});
|
});
|
||||||
|
|
||||||
const containsHexCode = (s) => {
|
|
||||||
return /\w*(&#x...)\w*/.test(s);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (containsHexCode(menuItemEl.textContent)) {
|
if (containsHexCode(menuItemEl.textContent)) {
|
||||||
// Replacement that allows innerHTML to be render properly.
|
// Replacement that allows innerHTML to be render properly.
|
||||||
menuItemEl.innerHTML = menuItemEl.textContent;
|
menuItemEl.innerHTML = menuItemEl.textContent;
|
||||||
|
@ -52,3 +52,15 @@ export const toTitleCase = function(string) {
|
|||||||
export const titleCaseEquals = function(str1, str2) {
|
export const titleCaseEquals = function(str1, str2) {
|
||||||
return toTitleCase(str1) === toTitleCase(str2);
|
return toTitleCase(str1) === toTitleCase(str2);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {string} string
|
||||||
|
* The string that will be tested
|
||||||
|
*
|
||||||
|
* @return {boolean}
|
||||||
|
* Whether the string contains a Hex Code
|
||||||
|
*/
|
||||||
|
export const containsHexCode = (string) => {
|
||||||
|
return /\w*(&#x.{2,4};)\w*/.test(string);
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user