Skip to content
This repository was archived by the owner on Aug 5, 2020. It is now read-only.

Commit 3a9aa47

Browse files
committed
Merge pull request #230 from mobify/v2.0-rename-method
Renames "escapedHTMLString" to "enabledHTMLString"
2 parents fbe2ed1 + 61544ac commit 3a9aa47

File tree

6 files changed

+19
-17
lines changed

6 files changed

+19
-17
lines changed

build/mobify.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,10 @@ Capture.prototype.createDocumentFragments = function() {
410410
};
411411

412412
/**
413-
* Returns an escaped HTML representation of the captured DOM
413+
* Returns an HTML representation of the captured DOM with resources enabled.
414+
* (escapedHTMLString remains for backwards compatibility)
414415
*/
415-
Capture.prototype.escapedHTMLString = function() {
416+
Capture.prototype.enabledHTMLString = Capture.prototype.escapedHTMLString = function() {
416417
var doc = this.capturedDoc;
417418
var html = Capture.enable(Utils.outerHTML(doc.documentElement), this.prefix);
418419
var htmlWithDoctype = this.doctype + html;
@@ -423,11 +424,11 @@ Capture.prototype.escapedHTMLString = function() {
423424
* Rewrite the document with a new html string
424425
*/
425426
Capture.prototype.render = function(htmlString) {
426-
var escapedHTMLString;
427+
var enabledHTMLString;
427428
if (!htmlString) {
428-
escapedHTMLString = this.escapedHTMLString();
429+
enabledHTMLString = this.enabledHTMLString();
429430
} else {
430-
escapedHTMLString = Capture.enable(htmlString, this.prefix);
431+
enabledHTMLString = Capture.enable(htmlString, this.prefix);
431432
}
432433

433434
var doc = this.sourceDoc;
@@ -438,7 +439,7 @@ Capture.prototype.render = function(htmlString) {
438439
// Asynchronously render the new document
439440
setTimeout(function(){
440441
doc.open("text/html", "replace");
441-
doc.write(escapedHTMLString);
442+
doc.write(enabledHTMLString);
442443
doc.close();
443444
});
444445
};

build/mobify.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/capture.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,10 @@ Capture.prototype.createDocumentFragments = function() {
409409
};
410410

411411
/**
412-
* Returns an escaped HTML representation of the captured DOM
412+
* Returns an HTML representation of the captured DOM with resources enabled.
413+
* (escapedHTMLString remains for backwards compatibility)
413414
*/
414-
Capture.prototype.escapedHTMLString = function() {
415+
Capture.prototype.enabledHTMLString = Capture.prototype.escapedHTMLString = function() {
415416
var doc = this.capturedDoc;
416417
var html = Capture.enable(Utils.outerHTML(doc.documentElement), this.prefix);
417418
var htmlWithDoctype = this.doctype + html;
@@ -422,11 +423,11 @@ Capture.prototype.escapedHTMLString = function() {
422423
* Rewrite the document with a new html string
423424
*/
424425
Capture.prototype.render = function(htmlString) {
425-
var escapedHTMLString;
426+
var enabledHTMLString;
426427
if (!htmlString) {
427-
escapedHTMLString = this.escapedHTMLString();
428+
enabledHTMLString = this.enabledHTMLString();
428429
} else {
429-
escapedHTMLString = Capture.enable(htmlString, this.prefix);
430+
enabledHTMLString = Capture.enable(htmlString, this.prefix);
430431
}
431432

432433
var doc = this.sourceDoc;
@@ -437,7 +438,7 @@ Capture.prototype.render = function(htmlString) {
437438
// Asynchronously render the new document
438439
setTimeout(function(){
439440
doc.open("text/html", "replace");
440-
doc.write(escapedHTMLString);
441+
doc.write(enabledHTMLString);
441442
doc.close();
442443
});
443444
};

tests/capture.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
\n\
136136
\n\
137137
\n</body></html>";
138-
var html = capture.escapedHTMLString(capturedDoc);
138+
var html = capture.enabledHTMLString(capturedDoc);
139139
equal(html, expectedHtml, "Passed!");
140140
start();
141141
}, doc);

www/_includes/nav-docsv2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
- [`Capture.init()`]({{ site.baseurl }}/v2/docs/capturing/#captureinitcallback-document-prefixx-)
66
- [`getCapturedDoc()`]({{ site.baseurl }}/v2/docs/capturing/#getcaptureddoc)
77
- [`capturing` variable]({{ site.baseurl }}/v2/docs/capturing/#capturing-variable)
8-
- [`escapedHTMLString()`]({{ site.baseurl }}/v2/docs/capturing/#escapedhtmlstring)
8+
- [`enabledHTMLString()`]({{ site.baseurl }}/v2/docs/capturing/#enabledhtmlstring)
99
- [`render(htmlString)`]({{ site.baseurl }}/v2/docs/capturing/#renderhtmlstring)
1010
- [`renderCapturedDoc()`]({{ site.baseurl }}/v2/docs/capturing/#rendercaptureddoc)
1111
- [`restore()`]({{ site.baseurl }}/v2/docs/capturing/#restore)

www/v2/docs/capturing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Mobify.js is run again in a non-capturing context (at this time
9393
}
9494

9595

96-
## `escapedHTMLString()`
96+
## `enabledHTMLString()`
9797

9898
Returns a string representation of the `captured document`, but with
9999
all resources enabled (prefix removed). Can be considered an
@@ -102,7 +102,7 @@ alternative to `capturedDoc.outerHTML`.
102102
**Usage/Example:**
103103

104104
Mobify.Capture.init(function(capture){
105-
var htmlString = capture.escapedHTMLString();
105+
var htmlString = capture.enabledHTMLString();
106106
});
107107

108108
## `render(htmlString)`

0 commit comments

Comments
 (0)