+ this.trigger('contentSet');
+ },
+
+ normalizeXML: function(nativeNode) {
+ var doc = this,
+ prefixLength = 'dc:'.length;
+
+ $(nativeNode).find('metadata').each(function() {
+ var metadataNode = $(this),
+ owner = doc.createDocumentNode(metadataNode.parent()[0]),
+ metadata = owner.getMetadata();
+
+ metadataNode.children().each(function() {
+ metadata.add({key: (this.tagName).toLowerCase().substr(prefixLength), value: $(this).text()}, {undoable: false});
+ });
+ metadataNode.remove();
+ });
+ nativeNode.normalize();
+ $(nativeNode).find('*').each(function() {
+ var emptyNode = this.childNodes.length === 0;
+ var endsWithSpan = !emptyNode && this.childNodes[this.childNodes.length - 1].nodeName.toLowerCase() === 'span';
+ if(emptyNode || endsWithSpan) {
+ var fakeTextNode = window.document.createTextNode("");
+ this.appendChild(fakeTextNode);
+ }
+ });
+
+ $(nativeNode).find(':not(iframe)').addBack().contents()