Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(respec-ready): s/respectIsReady/respecIsReady/ typo #716

Merged
merged 1 commit into from
May 2, 2016
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 14 additions & 13 deletions js/core/respec-ready.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
/**
* This Module adds a `respectIsReady` property to the document object.
* The property returns a promise.
* This Module adds a `respecIsReady` property to the document object.
* The property returns a promise that settles when ReSpec finishes
* processing the document.
*/

"use strict";
define(["Promise"], function() {
define([], function () {
var respecDone = false;
var doneResolver;
var doneRejector;
var respecDonePromise = new Promise(function(resolve, reject) {
var respecDonePromise = new Promise(function (resolve, reject) {
doneResolver = resolve;
doneRejector = reject;
});
Object.defineProperty(document, "respecDone", {
get: function() {
var warn = "document.respecDone is deprecated, use document.respectIsReady instead.";
get: function () {
var warn = "document.respecDone is deprecated, use document.respecIsReady instead.";
console.warn(warn);
return respecDone;
},
set: function(value) {
set: function (value) {
if (typeof value === "boolean" && value) {
respecDone = value;
doneResolver(respecConfig);
respecDone = value;
doneResolver(respecConfig);
}
if (value instanceof Error) {
doneRejector(value)
doneRejector(value)
}
return value;
}
});
Object.defineProperty(document, "respectIsReady", {
get: function() {
Object.defineProperty(document, "respecIsReady", {
get: function () {
return respecDonePromise;
},
});
return {};
});
});
2 changes: 1 addition & 1 deletion js/profile-w3c-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ define([
ui.addCommand("Search Specref DB", "ui/search-specref", "Ctrl+Shift+Alt+space");
runner
.runAll(args)
.then(document.respectIsReady)
.then(document.respecIsReady)
.then(ui.show)
.catch(function(err){
console.error(err);
Expand Down
10 changes: 5 additions & 5 deletions tests/spec/core/ready-promise-spec.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
"use strict";
describe("respectIsReady promise", function() {
describe("respecIsReady promise", function() {
it("should settle when processing is done", function(done) {
var ops = makeStandardOps();
makeRSDoc(ops, function(doc) {
var props = new Set(Object.getOwnPropertyNames(doc));
expect(props.has("respectIsReady")).toBeTruthy();
expect(doc.respectIsReady instanceof doc.defaultView.Promise).toBeTruthy();
doc.respectIsReady.then(done);
expect(props.has("respecIsReady")).toBeTruthy();
expect(doc.respecIsReady instanceof doc.defaultView.Promise).toBeTruthy();
doc.respecIsReady.then(done);
});
});

it("should resolve with the resulting respecConfig", function(done) {
var ops = makeStandardOps();
makeRSDoc(ops, function(doc) {
doc.respectIsReady.then(function(resultingConfig) {
doc.respecIsReady.then(function(resultingConfig) {
// previousPublishDate gets changed to a Date object by ReSpec,
// so not worth checking for equality.
delete resultingConfig.previousPublishDate;
Expand Down
2 changes: 1 addition & 1 deletion tools/respecDocWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const tasks = {
return document.readyState === "complete";
})
.evaluate(function(){
if(document.hasOwnProperty("respectIsReady")){
if(document.hasOwnProperty("respecIsReady")){
return true;
}
// does it try to load ReSpec locally or remotely
Expand Down