v1.1.6
This commit is contained in:
parent
18f5ae8347
commit
b9f65c2fdd
4 changed files with 65 additions and 51 deletions
24
mithril.js
24
mithril.js
|
|
@ -17,6 +17,10 @@ Vnode.normalizeChildren = function normalizeChildren(children) {
|
|||
var selectorParser = /(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g
|
||||
var selectorCache = {}
|
||||
var hasOwn = {}.hasOwnProperty
|
||||
function isEmpty(object) {
|
||||
for (var key in object) if (hasOwn.call(object, key)) return false
|
||||
return true
|
||||
}
|
||||
function compileSelector(selector) {
|
||||
var match, tag = "div", classes = [], attrs = {}
|
||||
while (match = selectorParser.exec(selector)) {
|
||||
|
|
@ -37,6 +41,15 @@ function compileSelector(selector) {
|
|||
function execSelector(state, attrs, children) {
|
||||
var hasAttrs = false, childList, text
|
||||
var className = attrs.className || attrs.class
|
||||
if (!isEmpty(state.attrs) && !isEmpty(attrs)) {
|
||||
var newAttrs = {}
|
||||
for(var key in attrs) {
|
||||
if (hasOwn.call(attrs, key)) {
|
||||
newAttrs[key] = attrs[key]
|
||||
}
|
||||
}
|
||||
attrs = newAttrs
|
||||
}
|
||||
for (var key in state.attrs) {
|
||||
if (hasOwn.call(state.attrs, key)) {
|
||||
attrs[key] = state.attrs[key]
|
||||
|
|
@ -805,9 +818,10 @@ var coreRenderer = function($window) {
|
|||
}
|
||||
function onremove(vnode) {
|
||||
if (vnode.attrs && typeof vnode.attrs.onremove === "function") vnode.attrs.onremove.call(vnode.state, vnode)
|
||||
if (typeof vnode.tag !== "string" && typeof vnode._state.onremove === "function") vnode._state.onremove.call(vnode.state, vnode)
|
||||
if (vnode.instance != null) onremove(vnode.instance)
|
||||
else {
|
||||
if (typeof vnode.tag !== "string") {
|
||||
if (typeof vnode._state.onremove === "function") vnode._state.onremove.call(vnode.state, vnode)
|
||||
if (vnode.instance != null) onremove(vnode.instance)
|
||||
} else {
|
||||
var children = vnode.children
|
||||
if (Array.isArray(children)) {
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
|
|
@ -968,9 +982,9 @@ var coreRenderer = function($window) {
|
|||
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
|
||||
for (var i = 0; i < hooks.length; i++) hooks[i]()
|
||||
// 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()
|
||||
for (var i = 0; i < hooks.length; i++) hooks[i]()
|
||||
}
|
||||
return {render: render, setEventCallback: setEventCallback}
|
||||
}
|
||||
|
|
@ -1236,7 +1250,7 @@ m.request = requestService.request
|
|||
m.jsonp = requestService.jsonp
|
||||
m.parseQueryString = parseQueryString
|
||||
m.buildQueryString = buildQueryString
|
||||
m.version = "1.1.5"
|
||||
m.version = "1.1.6"
|
||||
m.vnode = Vnode
|
||||
if (typeof module !== "undefined") module["exports"] = m
|
||||
else window.m = m
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue