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

Renames "escapedHTMLString" to "enabledHTMLString" #230

Merged
merged 5 commits into from
Mar 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions build/mobify.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,10 @@ Capture.prototype.createDocumentFragments = function() {
};

/**
* Returns an escaped HTML representation of the captured DOM
* Returns an HTML representation of the captured DOM with resources enabled.
* (escapedHTMLString remains for backwards compatibility)
*/
Capture.prototype.escapedHTMLString = function() {
Capture.prototype.enabledHTMLString = Capture.prototype.escapedHTMLString = function() {
var doc = this.capturedDoc;
var html = Capture.enable(Utils.outerHTML(doc.documentElement), this.prefix);
var htmlWithDoctype = this.doctype + html;
Expand All @@ -423,11 +424,11 @@ Capture.prototype.escapedHTMLString = function() {
* Rewrite the document with a new html string
*/
Capture.prototype.render = function(htmlString) {
var escapedHTMLString;
var enabledHTMLString;
if (!htmlString) {
escapedHTMLString = this.escapedHTMLString();
enabledHTMLString = this.enabledHTMLString();
} else {
escapedHTMLString = Capture.enable(htmlString, this.prefix);
enabledHTMLString = Capture.enable(htmlString, this.prefix);
}

var doc = this.sourceDoc;
Expand All @@ -438,7 +439,7 @@ Capture.prototype.render = function(htmlString) {
// Asynchronously render the new document
setTimeout(function(){
doc.open("text/html", "replace");
doc.write(escapedHTMLString);
doc.write(enabledHTMLString);
doc.close();
});
};
Expand Down
2 changes: 1 addition & 1 deletion build/mobify.min.js

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions src/capture.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,10 @@ Capture.prototype.createDocumentFragments = function() {
};

/**
* Returns an escaped HTML representation of the captured DOM
* Returns an HTML representation of the captured DOM with resources enabled.
* (escapedHTMLString remains for backwards compatibility)
*/
Capture.prototype.escapedHTMLString = function() {
Capture.prototype.enabledHTMLString = Capture.prototype.escapedHTMLString = function() {
var doc = this.capturedDoc;
var html = Capture.enable(Utils.outerHTML(doc.documentElement), this.prefix);
var htmlWithDoctype = this.doctype + html;
Expand All @@ -422,11 +423,11 @@ Capture.prototype.escapedHTMLString = function() {
* Rewrite the document with a new html string
*/
Capture.prototype.render = function(htmlString) {
var escapedHTMLString;
var enabledHTMLString;
if (!htmlString) {
escapedHTMLString = this.escapedHTMLString();
enabledHTMLString = this.enabledHTMLString();
} else {
escapedHTMLString = Capture.enable(htmlString, this.prefix);
enabledHTMLString = Capture.enable(htmlString, this.prefix);
}

var doc = this.sourceDoc;
Expand All @@ -437,7 +438,7 @@ Capture.prototype.render = function(htmlString) {
// Asynchronously render the new document
setTimeout(function(){
doc.open("text/html", "replace");
doc.write(escapedHTMLString);
doc.write(enabledHTMLString);
doc.close();
});
};
Expand Down
2 changes: 1 addition & 1 deletion tests/capture.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
\n\
\n\
\n</body></html>";
var html = capture.escapedHTMLString(capturedDoc);
var html = capture.enabledHTMLString(capturedDoc);
equal(html, expectedHtml, "Passed!");
start();
}, doc);
Expand Down
2 changes: 1 addition & 1 deletion www/_includes/nav-docsv2.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- [`Capture.init()`]({{ site.baseurl }}/v2/docs/capturing/#captureinitcallback-document-prefixx-)
- [`getCapturedDoc()`]({{ site.baseurl }}/v2/docs/capturing/#getcaptureddoc)
- [`capturing` variable]({{ site.baseurl }}/v2/docs/capturing/#capturing-variable)
- [`escapedHTMLString()`]({{ site.baseurl }}/v2/docs/capturing/#escapedhtmlstring)
- [`enabledHTMLString()`]({{ site.baseurl }}/v2/docs/capturing/#enabledhtmlstring)
- [`render(htmlString)`]({{ site.baseurl }}/v2/docs/capturing/#renderhtmlstring)
- [`renderCapturedDoc()`]({{ site.baseurl }}/v2/docs/capturing/#rendercaptureddoc)
- [`restore()`]({{ site.baseurl }}/v2/docs/capturing/#restore)
Expand Down
4 changes: 2 additions & 2 deletions www/v2/docs/capturing.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Mobify.js is run again in a non-capturing context (at this time
}


## `escapedHTMLString()`
## `enabledHTMLString()`

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

Mobify.Capture.init(function(capture){
var htmlString = capture.escapedHTMLString();
var htmlString = capture.enabledHTMLString();
});

## `render(htmlString)`
Expand Down