From 8867ca067b8cd6d88eee386f00f15a031c297a79 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Mon, 6 May 2013 23:09:11 +0200 Subject: [PATCH] Visual editor - adding metadata node if missing --- modules/visualEditor.transformations.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/visualEditor.transformations.js b/modules/visualEditor.transformations.js index d45109f..8a32831 100644 --- a/modules/visualEditor.transformations.js +++ b/modules/visualEditor.transformations.js @@ -91,7 +91,16 @@ if(typeof module !== 'undefined' && module.exports) { }); meta.append('\n'); - toret.find('metadata').replaceWith(meta); + var metadata = toret.find('metadata'); + if(metadata.length === 0) { + var section = toret.find('section'); + section = section.length ? $(section[0]) : null; + if(section) { + section.prepend(meta) + } + } else { + metadata.replaceWith(meta); + } return vkbeautify.xml(toret.html()); -- 2.20.1