From c34202af0ab9a434ae121b780b0d5f2205ece185 Mon Sep 17 00:00:00 2001 From: Janez Urevc Date: Wed, 30 Oct 2013 21:13:19 +0100 Subject: [PATCH 1/4] by slashrsm: Add support for comment-wrapped esi tags. ESI spec allows comment wrapped ESI tags (i.e. ""), which are ignored by jquery.esi.js. Added support for them. --- jquery.esi.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/jquery.esi.js b/jquery.esi.js index 0bf8f9d..23e9870 100755 --- a/jquery.esi.js +++ b/jquery.esi.js @@ -30,6 +30,13 @@ // Retrieve the base DOM element, in order to access the DOM method // getElementsByTagName. base_element = $(this).get(0); + // Discover comment-wrapped tags and move them out of the comment. + jQuery("*").contents() + .filter(function(){ return this.nodeType == 8 && this.nodeValue.match(/^esi/);}) + .each(function(){ + var dom = $.trim(this.nodeValue).replace('/^esi/','').trim(); + $(this).after(dom); + }); // Discover the tags. jQuery.each(base_element.getElementsByTagName('esi:include'), function(i, val) { // Some DOMs fail to recognise that the ESI include tag is self- From c6ba83dc1a54eef2ce6a631869cac3df0c0a1571 Mon Sep 17 00:00:00 2001 From: Janez Urevc Date: Wed, 30 Oct 2013 21:42:13 +0100 Subject: [PATCH 2/4] by slashrsm: Fix regular expression - make it actually an regexp. --- jquery.esi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.esi.js b/jquery.esi.js index 23e9870..7a2b8ea 100755 --- a/jquery.esi.js +++ b/jquery.esi.js @@ -34,7 +34,7 @@ jQuery("*").contents() .filter(function(){ return this.nodeType == 8 && this.nodeValue.match(/^esi/);}) .each(function(){ - var dom = $.trim(this.nodeValue).replace('/^esi/','').trim(); + var dom = $.trim(this.nodeValue).replace(/^esi/,'').trim(); $(this).after(dom); }); // Discover the tags. From 0ce18e212038740fbedee8195d1c41246e50ba57 Mon Sep 17 00:00:00 2001 From: Janez Urevc Date: Thu, 31 Oct 2013 17:23:08 +0100 Subject: [PATCH 3/4] by slashrsm: Remove ESI comment after being converted to standard ESI tag. --- jquery.esi.js | 1 + 1 file changed, 1 insertion(+) diff --git a/jquery.esi.js b/jquery.esi.js index 7a2b8ea..c08e8f0 100755 --- a/jquery.esi.js +++ b/jquery.esi.js @@ -36,6 +36,7 @@ .each(function(){ var dom = $.trim(this.nodeValue).replace(/^esi/,'').trim(); $(this).after(dom); + $(this).remove(); }); // Discover the tags. jQuery.each(base_element.getElementsByTagName('esi:include'), function(i, val) { From 99b2547f29ae774d4826039e88909b3fd67d1131 Mon Sep 17 00:00:00 2001 From: Janez Urevc Date: Tue, 19 Nov 2013 16:13:15 +0100 Subject: [PATCH 4/4] by slashrsm: Fix error with comment-wrapped esi tags when there are outside iframes on page. iframes that pull content from other URLs can cause errors like this: "Blocked a frame with origin "http://web1.dev.examiner.com" from accessing a frame with origin "http://www.facebook.com". The frame being accessed set "document.domain" to "facebook.com", but the frame requesting access did not. Both must set "document.domain" to the same value to allow access." There is no point in looking for esi tags inside iframes anyway so let's exclude them. --- jquery.esi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.esi.js b/jquery.esi.js index c08e8f0..330f65c 100755 --- a/jquery.esi.js +++ b/jquery.esi.js @@ -31,7 +31,7 @@ // getElementsByTagName. base_element = $(this).get(0); // Discover comment-wrapped tags and move them out of the comment. - jQuery("*").contents() + jQuery("*:not(iframe)").contents() .filter(function(){ return this.nodeType == 8 && this.nodeValue.match(/^esi/);}) .each(function(){ var dom = $.trim(this.nodeValue).replace(/^esi/,'').trim();