fix disappearing link text

This commit is contained in:
Leo Horie 2014-04-08 21:33:00 -04:00
parent 9dcffab2ac
commit d684b0fceb
7 changed files with 17 additions and 9 deletions

View file

@ -126,6 +126,7 @@ new function(window) {
var dataAttr = dataAttrs[attrName] var dataAttr = dataAttrs[attrName]
var cachedAttr = cachedAttrs[attrName] var cachedAttr = cachedAttrs[attrName]
if (!(attrName in cachedAttrs) || (cachedAttr !== dataAttr) || node === window.document.activeElement) { if (!(attrName in cachedAttrs) || (cachedAttr !== dataAttr) || node === window.document.activeElement) {
cachedAttrs[attrName] = dataAttr
if (attrName === "config") continue if (attrName === "config") continue
else if (typeof dataAttr == "function" && attrName.indexOf("on") == 0) { else if (typeof dataAttr == "function" && attrName.indexOf("on") == 0) {
if (String(dataAttr) !== String(cachedAttr)) node[attrName] = autoredraw(dataAttr, node) if (String(dataAttr) !== String(cachedAttr)) node[attrName] = autoredraw(dataAttr, node)
@ -137,7 +138,6 @@ new function(window) {
} }
else if (attrName in node) node[attrName] = dataAttr else if (attrName in node) node[attrName] = dataAttr
else node.setAttribute(attrName, dataAttr) else node.setAttribute(attrName, dataAttr)
cachedAttrs[attrName] = dataAttr
} }
} }
return cachedAttrs return cachedAttrs
@ -673,6 +673,12 @@ function testMithril(mock) {
m.render(root, m("ul", [{subtree: "retain"}])) m.render(root, m("ul", [{subtree: "retain"}]))
return root.childNodes[0].childNodes[0].childNodes[0].nodeName === "A" return root.childNodes[0].childNodes[0].childNodes[0].nodeName === "A"
}) })
test(function() {
var root = mock.document.createElement("div")
m.render(root, m("a", {config: m.route}, "test"))
m.render(root, m("a", {config: m.route}, "test"))
return root.childNodes[0].childNodes[0].nodeValue === "test"
})
//m.redraw //m.redraw
test(function() { test(function() {
@ -796,14 +802,12 @@ function testMithril(mock) {
var prop = m.request({method: "POST", url: "http://domain.com:80", data: {}}).then(function(value) {return value}) var prop = m.request({method: "POST", url: "http://domain.com:80", data: {}}).then(function(value) {return value})
var e = mock.XMLHttpRequest.$events.pop() var e = mock.XMLHttpRequest.$events.pop()
e.target.onload(e) e.target.onload(e)
console.log(prop().url)
return prop().url === "http://domain.com:80" return prop().url === "http://domain.com:80"
}) })
test(function() { test(function() {
var prop = m.request({method: "POST", url: "http://domain.com:80/:test1", data: {test1: "foo"}}).then(function(value) {return value}) var prop = m.request({method: "POST", url: "http://domain.com:80/:test1", data: {test1: "foo"}}).then(function(value) {return value})
var e = mock.XMLHttpRequest.$events.pop() var e = mock.XMLHttpRequest.$events.pop()
e.target.onload(e) e.target.onload(e)
console.log(prop().url)
return prop().url === "http://domain.com:80/foo" return prop().url === "http://domain.com:80/foo"
}) })

View file

@ -126,6 +126,7 @@ new function(window) {
var dataAttr = dataAttrs[attrName] var dataAttr = dataAttrs[attrName]
var cachedAttr = cachedAttrs[attrName] var cachedAttr = cachedAttrs[attrName]
if (!(attrName in cachedAttrs) || (cachedAttr !== dataAttr) || node === window.document.activeElement) { if (!(attrName in cachedAttrs) || (cachedAttr !== dataAttr) || node === window.document.activeElement) {
cachedAttrs[attrName] = dataAttr
if (attrName === "config") continue if (attrName === "config") continue
else if (typeof dataAttr == "function" && attrName.indexOf("on") == 0) { else if (typeof dataAttr == "function" && attrName.indexOf("on") == 0) {
if (String(dataAttr) !== String(cachedAttr)) node[attrName] = autoredraw(dataAttr, node) if (String(dataAttr) !== String(cachedAttr)) node[attrName] = autoredraw(dataAttr, node)
@ -137,7 +138,6 @@ new function(window) {
} }
else if (attrName in node) node[attrName] = dataAttr else if (attrName in node) node[attrName] = dataAttr
else node.setAttribute(attrName, dataAttr) else node.setAttribute(attrName, dataAttr)
cachedAttrs[attrName] = dataAttr
} }
} }
return cachedAttrs return cachedAttrs

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

View file

@ -126,6 +126,7 @@ new function(window) {
var dataAttr = dataAttrs[attrName] var dataAttr = dataAttrs[attrName]
var cachedAttr = cachedAttrs[attrName] var cachedAttr = cachedAttrs[attrName]
if (!(attrName in cachedAttrs) || (cachedAttr !== dataAttr) || node === window.document.activeElement) { if (!(attrName in cachedAttrs) || (cachedAttr !== dataAttr) || node === window.document.activeElement) {
cachedAttrs[attrName] = dataAttr
if (attrName === "config") continue if (attrName === "config") continue
else if (typeof dataAttr == "function" && attrName.indexOf("on") == 0) { else if (typeof dataAttr == "function" && attrName.indexOf("on") == 0) {
if (String(dataAttr) !== String(cachedAttr)) node[attrName] = autoredraw(dataAttr, node) if (String(dataAttr) !== String(cachedAttr)) node[attrName] = autoredraw(dataAttr, node)
@ -137,7 +138,6 @@ new function(window) {
} }
else if (attrName in node) node[attrName] = dataAttr else if (attrName in node) node[attrName] = dataAttr
else node.setAttribute(attrName, dataAttr) else node.setAttribute(attrName, dataAttr)
cachedAttrs[attrName] = dataAttr
} }
} }
return cachedAttrs return cachedAttrs

View file

@ -141,6 +141,12 @@ function testMithril(mock) {
m.render(root, m("ul", [{subtree: "retain"}])) m.render(root, m("ul", [{subtree: "retain"}]))
return root.childNodes[0].childNodes[0].childNodes[0].nodeName === "A" return root.childNodes[0].childNodes[0].childNodes[0].nodeName === "A"
}) })
test(function() {
var root = mock.document.createElement("div")
m.render(root, m("a", {config: m.route}, "test"))
m.render(root, m("a", {config: m.route}, "test"))
return root.childNodes[0].childNodes[0].nodeValue === "test"
})
//m.redraw //m.redraw
test(function() { test(function() {
@ -264,14 +270,12 @@ function testMithril(mock) {
var prop = m.request({method: "POST", url: "http://domain.com:80", data: {}}).then(function(value) {return value}) var prop = m.request({method: "POST", url: "http://domain.com:80", data: {}}).then(function(value) {return value})
var e = mock.XMLHttpRequest.$events.pop() var e = mock.XMLHttpRequest.$events.pop()
e.target.onload(e) e.target.onload(e)
console.log(prop().url)
return prop().url === "http://domain.com:80" return prop().url === "http://domain.com:80"
}) })
test(function() { test(function() {
var prop = m.request({method: "POST", url: "http://domain.com:80/:test1", data: {test1: "foo"}}).then(function(value) {return value}) var prop = m.request({method: "POST", url: "http://domain.com:80/:test1", data: {test1: "foo"}}).then(function(value) {return value})
var e = mock.XMLHttpRequest.$events.pop() var e = mock.XMLHttpRequest.$events.pop()
e.target.onload(e) e.target.onload(e)
console.log(prop().url)
return prop().url === "http://domain.com:80/foo" return prop().url === "http://domain.com:80/foo"
}) })