Skip to content

Commit

Permalink
Revert on-load attribute special case (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
greghuc authored and yoshuawuyts committed May 22, 2017
1 parent 127c60a commit 81797fa
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 42 deletions.
19 changes: 0 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
var assert = require('assert')
var morph = require('./lib/morph')
var rootLabelRegex = /^data-onloadid/

var ELEMENT_NODE = 1

module.exports = nanomorph

Expand All @@ -22,8 +19,6 @@ module.exports = nanomorph
function nanomorph (oldTree, newTree) {
assert.equal(typeof oldTree, 'object', 'nanomorph: oldTree should be an object')
assert.equal(typeof newTree, 'object', 'nanomorph: newTree should be an object')

persistStatefulRoot(newTree, oldTree)
var tree = walk(newTree, oldTree)
return tree
}
Expand Down Expand Up @@ -87,17 +82,3 @@ function updateChildren (newNode, oldNode) {
newIndex = newStartIndex
}
}

function persistStatefulRoot (newNode, oldNode) {
if (!newNode || !oldNode || oldNode.nodeType !== ELEMENT_NODE || newNode.nodeType !== ELEMENT_NODE) return
var oldAttrs = oldNode.attributes
var attr, name
for (var i = 0, len = oldAttrs.length; i < len; i++) {
attr = oldAttrs[i]
name = attr.name
if (rootLabelRegex.test(name)) {
newNode.setAttribute(name, attr.value)
break
}
}
}
23 changes: 0 additions & 23 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,29 +294,6 @@ function abstractMorph (morph) {
})
}

tape('should skip over data-onload attributes at root', function (t) {
var a = html`
<section data-onloadidzina="o0">
<input data-onloadidzina="o1">
</section>
`
var b = html`
<section>
<input autofocus="autofocus" value="" class="f6 normal">
<button class="bg-light-gray white ttu">save</button>
</section>
`
var c = html`
<section data-onloadidzina="o0">
<input autofocus="autofocus" value="" class="f6 normal">
<button class="bg-light-gray white ttu">save</button>
</section>
`
var d = nanomorph(a, b)
t.ok(c.isEqualNode(d), 'is equal')
t.end()
})

tape('use id as a key hint', function (t) {
t.test('append an element', function (t) {
var a = html`<ul>
Expand Down

0 comments on commit 81797fa

Please sign in to comment.