Skip to content

Commit

Permalink
Fixed my bug!, dist
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrasser committed Dec 22, 2013
1 parent ec44a04 commit ec6cde5
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 18 deletions.
3 changes: 2 additions & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ <h3 id="options">Options</h3>
</footer>


<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> -->
<script src="../bower_components/jquery/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.js"></script>
<script src="dist/jquery.linkify.js"></script>
Expand Down
38 changes: 30 additions & 8 deletions dist/jquery.linkify.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
};

/**
Given a DOM node, linkify its contents
Given an HTML DOM node, linkify its contents
*/
Linkified.linkifyNode = function (node) {

Expand Down Expand Up @@ -284,7 +284,18 @@

if (childNode.nodeType === 3) {

// Linkify the text node
/*
Cleanup dummy node. This is to make sure that
existing nodes don't get improperly removed
*/
while (dummyElement.firstChild) {
dummyElement.removeChild(dummyElement.firstChild);
}

/*
Linkify the text node, set the result to the
dummy's contents
*/
dummyElement.innerHTML = Linkified.linkify.call(
this,
childNode.textContent || childNode.innerText
Expand All @@ -299,27 +310,38 @@
dummyElement.childNodes
);

// Clean up the dummy
while (dummyElement.firstChild) {
dummyElement.removeChild(dummyElement.firstChild);
}

} else if (childNode.nodeType === 1) {

// This is an HTML node, linkify it and add it
children.push(Linkified.linkifyNode(childNode));

} else {

// This is some other kind of node, just push it
children.push(childNode);
}

childNode = childNode.nextSibling;
}

// Replace nodes with the new ones
for (i = 0; i < childCount; i++) {
console.log(node.childNodes[i], children[i], i);
node.replaceChild(children[i], node.childNodes[i]);

// Remove all existing nodes.
while (node.firstChild) {
node.removeChild(node.firstChild);
}

for (i; i < children.length; i++) {
console.log(children[i], i);
// Replace with all the new nodes
for (i = 0; i < children.length; i++) {
node.appendChild(children[i]);
}

}
console.log("\n", children);
return node;
},

Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.linkify.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 30 additions & 8 deletions src/linkified.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
};

/**
Given a DOM node, linkify its contents
Given an HTML DOM node, linkify its contents
*/
Linkified.linkifyNode = function (node) {

Expand Down Expand Up @@ -276,7 +276,18 @@

if (childNode.nodeType === 3) {

// Linkify the text node
/*
Cleanup dummy node. This is to make sure that
existing nodes don't get improperly removed
*/
while (dummyElement.firstChild) {
dummyElement.removeChild(dummyElement.firstChild);
}

/*
Linkify the text node, set the result to the
dummy's contents
*/
dummyElement.innerHTML = Linkified.linkify.call(
this,
childNode.textContent || childNode.innerText
Expand All @@ -291,27 +302,38 @@
dummyElement.childNodes
);

// Clean up the dummy
while (dummyElement.firstChild) {
dummyElement.removeChild(dummyElement.firstChild);
}

} else if (childNode.nodeType === 1) {

// This is an HTML node, linkify it and add it
children.push(Linkified.linkifyNode(childNode));

} else {

// This is some other kind of node, just push it
children.push(childNode);
}

childNode = childNode.nextSibling;
}

// Replace nodes with the new ones
for (i = 0; i < childCount; i++) {
console.log(node.childNodes[i], children[i], i);
node.replaceChild(children[i], node.childNodes[i]);

// Remove all existing nodes.
while (node.firstChild) {
node.removeChild(node.firstChild);
}

for (i; i < children.length; i++) {
console.log(children[i], i);
// Replace with all the new nodes
for (i = 0; i < children.length; i++) {
node.appendChild(children[i]);
}

}
console.log("\n", children);
return node;
},

Expand Down

0 comments on commit ec6cde5

Please sign in to comment.