Skip to content

Commit

Permalink
ES5 fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Feb 13, 2019
1 parent 2c8abb9 commit d6b8501
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions js/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i

function allowedAttribute(attr, allowedAttributeList) {
const attrName = attr.nodeName.toLowerCase()
var attrName = attr.nodeName.toLowerCase()

if ($.inArray(attrName, allowedAttributeList) !== -1) {
if ($.inArray(attrName, uriAttrs) !== -1) {
Expand Down Expand Up @@ -115,7 +115,7 @@
var createdDocument = document.implementation.createHTMLDocument('sanitization')
createdDocument.body.innerHTML = unsafeHtml

var whitelistKeys = Object.keys(whiteList)
var whitelistKeys = $.map(whiteList, function (el, i) { return i })
var elements = $(createdDocument.body).find('*')

for (var i = 0, len = elements.length; i < len; i++) {
Expand All @@ -131,11 +131,11 @@
var attributeList = $.map(el.attributes, function (el) { return el })
var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || [])

attributeList.forEach((attr) => {
if (!allowedAttribute(attr, whitelistedAttributes)) {
el.removeAttribute(attr.nodeName)
for (var j = 0, len2 = attributeList.length; j < len2; j++) {
if (!allowedAttribute(attributeList[j], whitelistedAttributes)) {
el.removeAttribute(attributeList[j].nodeName)
}
})
}
}

return createdDocument.body.innerHTML
Expand Down Expand Up @@ -217,7 +217,7 @@
}

Tooltip.prototype.getOptions = function (options) {
const dataAttributes = this.$element.data()
var dataAttributes = this.$element.data()

for (var dataAttr in dataAttributes) {
if (dataAttributes.hasOwnProperty(dataAttr) && $.inArray(dataAttr, DISALLOWED_ATTRIBUTES) !== -1) {
Expand All @@ -235,7 +235,7 @@
}

if (options.sanitize) {
config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn)
options.template = sanitizeHtml(options.template, options.whiteList, options.sanitizeFn)
}

return options
Expand Down

0 comments on commit d6b8501

Please sign in to comment.