Skip to content

Commit

Permalink
v1.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-claudia committed Sep 23, 2019
1 parent 8d7ff39 commit 35ab329
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 59 deletions.
43 changes: 30 additions & 13 deletions mithril.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,15 @@ var coreRenderer = function($window) {
function getNameSpace(vnode) {
return vnode.attrs && vnode.attrs.xmlns || nameSpace[vnode.tag]
}
// IE9 - IE11 (at least) throw an UnspecifiedError when accessing document.activeElement when
// inside an iframe. Catch and swallow this error0, and heavy-handidly return null.
function activeElement() {
try {
return $doc.activeElement
} catch (e) {
return null
}
}
//create
function createNodes(parent, vnodes, start, end, hooks, nextSibling, ns) {
for (var i = start; i < end; i++) {
Expand Down Expand Up @@ -850,13 +859,13 @@ var coreRenderer = function($window) {
if (key2 === "value") {
var normalized0 = "" + value // eslint-disable-line no-implicit-coercion
//setting input[value] to same value by typing on focused element moves cursor to end in Chrome
if ((vnode.tag === "input" || vnode.tag === "textarea") && vnode.dom.value === normalized0 && vnode.dom === $doc.activeElement) return
if ((vnode.tag === "input" || vnode.tag === "textarea") && vnode.dom.value === normalized0 && vnode.dom === activeElement()) return
//setting select[value] to same value while having select open blinks select dropdown in Chrome
if (vnode.tag === "select") {
if (value === null) {
if (vnode.dom.selectedIndex === -1 && vnode.dom === $doc.activeElement) return
if (vnode.dom.selectedIndex === -1 && vnode.dom === activeElement()) return
} else {
if (old !== null && vnode.dom.value === normalized0 && vnode.dom === $doc.activeElement) return
if (old !== null && vnode.dom.value === normalized0 && vnode.dom === activeElement()) return
}
}
//setting option[value] to same value while having select open blinks select dropdown in Chrome
Expand Down Expand Up @@ -901,7 +910,7 @@ var coreRenderer = function($window) {
}
}
function isFormAttribute(vnode, attr) {
return attr === "value" || attr === "checked" || attr === "selectedIndex" || attr === "selected" && vnode.dom === $doc.activeElement
return attr === "value" || attr === "checked" || attr === "selectedIndex" || attr === "selected" && vnode.dom === activeElement()
}
function isLifecycleMethod(attr) {
return attr === "oninit" || attr === "oncreate" || attr === "onupdate" || attr === "onremove" || attr === "onbeforeremove" || attr === "onbeforeupdate"
Expand Down Expand Up @@ -975,15 +984,15 @@ var coreRenderer = function($window) {
function render(dom, vnodes) {
if (!dom) throw new Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.")
var hooks = []
var active = $doc.activeElement
var active = activeElement()
var namespace = dom.namespaceURI
// First time0 rendering into a node clears it out
if (dom.vnodes == null) dom.textContent = ""
if (!Array.isArray(vnodes)) vnodes = [vnodes]
updateNodes(dom, dom.vnodes, Vnode.normalizeChildren(vnodes), false, hooks, null, namespace === "http://www.w3.org/1999/xhtml" ? undefined : namespace)
dom.vnodes = vnodes
// document.activeElement can return null in IE https://developer.mozilla.org/en-US/docs/Web/API/Document/activeElement
if (active != null && $doc.activeElement !== active) active.focus()
if (active != null && activeElement() !== active) active.focus()
for (var i = 0; i < hooks.length; i++) hooks[i]()
}
return {render: render, setEventCallback: setEventCallback}
Expand Down Expand Up @@ -1054,7 +1063,7 @@ var Promise = PromisePolyfill
var parseQueryString = function(string) {
if (string === "" || string == null) return {}
if (string.charAt(0) === "?") string = string.slice(1)
var entries = string.split("&"), data0 = {}, counters = {}
var entries = string.split("&"), counters = {}, data0 = {}
for (var i = 0; i < entries.length; i++) {
var entry = entries[i].split("=")
var key5 = decodeURIComponent(entry[0])
Expand All @@ -1067,16 +1076,24 @@ var parseQueryString = function(string) {
for (var j = 0; j < levels.length; j++) {
var level = levels[j], nextLevel = levels[j + 1]
var isNumber = nextLevel == "" || !isNaN(parseInt(nextLevel, 10))
var isValue = j === levels.length - 1
if (level === "") {
var key5 = levels.slice(0, j).join()
if (counters[key5] == null) counters[key5] = 0
if (counters[key5] == null) {
counters[key5] = Array.isArray(cursor) ? cursor.length : 0
}
level = counters[key5]++
}
if (cursor[level] == null) {
cursor[level] = isValue ? value : isNumber ? [] : {}
// Disallow direct prototype pollution
else if (level === "__proto__") break
if (j === levels.length - 1) cursor[level] = value
else {
// Read own properties exclusively to disallow indirect
// prototype pollution
var desc = Object.getOwnPropertyDescriptor(cursor, level)
if (desc != null) desc = desc.value
if (desc == null) cursor[level] = desc = isNumber ? [] : {}
cursor = desc
}
cursor = cursor[level]
}
}
return data0
Expand Down Expand Up @@ -1250,7 +1267,7 @@ m.request = requestService.request
m.jsonp = requestService.jsonp
m.parseQueryString = parseQueryString
m.buildQueryString = buildQueryString
m.version = "1.1.6"
m.version = "1.1.7"
m.vnode = Vnode
if (typeof module !== "undefined") module["exports"] = m
else window.m = m
Expand Down

0 comments on commit 35ab329

Please sign in to comment.