diff --git a/build/aui-parse-content/aui-parse-content-debug.js b/build/aui-parse-content/aui-parse-content-debug.js
index dfc1e557e89..749a89946ec 100644
--- a/build/aui-parse-content/aui-parse-content-debug.js
+++ b/build/aui-parse-content/aui-parse-content-debug.js
@@ -24,6 +24,7 @@ var L = A.Lang,
PARSE_CONTENT = 'ParseContent',
QUEUE = 'queue',
SCRIPT = 'script',
+ SEMICOLON = ';',
SRC = 'src',
SCRIPT_TYPES = {
@@ -146,6 +147,7 @@ var ParseContent = A.Component.create(
*/
parseContent: function(content) {
var instance = this;
+
var output = instance._clean(content);
instance._dispatch(output);
@@ -153,6 +155,26 @@ var ParseContent = A.Component.create(
return output;
},
+ /**
+ * Add inline script data to the queue.
+ *
+ * @method _addInlineScript
+ * @param {String} data The script content which should be added to the queue
+ * @protected
+ */
+ _addInlineScript: function(data) {
+ var instance = this;
+
+ instance.get(QUEUE).add(
+ {
+ args: data,
+ context: instance,
+ fn: instance.globalEval,
+ timeout: 0
+ }
+ );
+ },
+
/**
* Bind listeners on the insert
and setContent
* methods of the Node instance where you are plugging the ParseContent.
@@ -242,12 +264,21 @@ var ParseContent = A.Component.create(
*/
_dispatch: function(output) {
var instance = this;
+
var queue = instance.get(QUEUE);
+ var scriptContent = [];
+
output.js.each(function(node, i) {
var src = node.get(SRC);
if (src) {
+ if (scriptContent.length) {
+ instance._addInlineScript(scriptContent.join(SEMICOLON));
+
+ scriptContent.length = 0;
+ }
+
queue.add({
autoContinue: false,
fn: function () {
@@ -262,19 +293,16 @@ var ParseContent = A.Component.create(
});
}
else {
- queue.add({
- fn: function () {
- var dom = node._node;
+ var dom = node._node;
- instance.globalEval(
- dom.text || dom.textContent || dom.innerHTML || ''
- );
- },
- timeout: 0
- });
+ scriptContent.push(dom.text || dom.textContent || dom.innerHTML || '');
}
});
+ if (scriptContent.length) {
+ instance._addInlineScript(scriptContent.join(SEMICOLON));
+ }
+
queue.run();
}
}
diff --git a/build/aui-parse-content/aui-parse-content-min.js b/build/aui-parse-content/aui-parse-content-min.js
index 63f8cb3f464..46f3d98aaf0 100644
--- a/build/aui-parse-content/aui-parse-content-min.js
+++ b/build/aui-parse-content/aui-parse-content-min.js
@@ -1 +1 @@
-AUI.add("aui-parse-content",function(d){var l=d.Lang,c=l.isString,m="append",a="documentElement",o="firstChild",i="head",n="host",f="innerHTML",g="ParseContent",e="queue",k="script",h="src",j={"":1,"text/javascript":1};var b=d.Component.create({NAME:g,NS:g,ATTRS:{queue:{value:null}},EXTENDS:d.Plugin.Base,prototype:{initializer:function(){var p=this;b.superclass.initializer.apply(this,arguments);p.set(e,new d.AsyncQueue());p._bindAOP();},globalEval:function(r){var s=d.getDoc();var q=s.one(i)||s.get(a);var p=document.createElement(k);p.type="text/javascript";if(r){p.text=l.trim(r);}q.appendChild(p).remove();},parseContent:function(r){var p=this;var q=p._clean(r);p._dispatch(q);return q;},_bindAOP:function(){var q=this;var p=function(u){var t=Array.prototype.slice.call(arguments);var s=q.parseContent(u);t.splice(0,1,s.fragment);return new d.Do.AlterArgs(null,t);};this.doBefore("insert",p);this.doBefore("replaceChild",p);var r=function(t){var s=q.parseContent(t);return new d.Do.AlterArgs(null,[s.fragment]);};this.doBefore("replace",r);this.doBefore("setContent",r);},_clean:function(r){var p={};var q=d.Node.create("
insert
and setContent
* methods of the Node instance where you are plugging the ParseContent.
@@ -242,12 +264,21 @@ var ParseContent = A.Component.create(
*/
_dispatch: function(output) {
var instance = this;
+
var queue = instance.get(QUEUE);
+ var scriptContent = [];
+
output.js.each(function(node, i) {
var src = node.get(SRC);
if (src) {
+ if (scriptContent.length) {
+ instance._addInlineScript(scriptContent.join(SEMICOLON));
+
+ scriptContent.length = 0;
+ }
+
queue.add({
autoContinue: false,
fn: function () {
@@ -262,19 +293,16 @@ var ParseContent = A.Component.create(
});
}
else {
- queue.add({
- fn: function () {
- var dom = node._node;
+ var dom = node._node;
- instance.globalEval(
- dom.text || dom.textContent || dom.innerHTML || ''
- );
- },
- timeout: 0
- });
+ scriptContent.push(dom.text || dom.textContent || dom.innerHTML || '');
}
});
+ if (scriptContent.length) {
+ instance._addInlineScript(scriptContent.join(SEMICOLON));
+ }
+
queue.run();
}
}