Use Promise.async/yield in lib/ext/Cite

Change-Id: I08458b0083de8d9aec9673af7f08c4b2e25112e5
This commit is contained in:
C. Scott Ananian 2018-02-16 15:46:15 -05:00 committed by jenkins-bot
parent 8713e6cb55
commit fd719e02e2

View file

@ -113,9 +113,8 @@ Ref.prototype.tokenHandler = function(manager, pipelineOpts, refTok, cb) {
}; };
Ref.prototype.serialHandler = { Ref.prototype.serialHandler = {
handle: Promise.method(function(node, state, wrapperUnmodified) { handle: Promise.async(function *(node, state, wrapperUnmodified) {
return state.serializer.serializeExtensionStartTag(node, state) var startTagSrc = yield state.serializer.serializeExtensionStartTag(node, state);
.then(function(startTagSrc) {
var dataMw = DU.getDataMw(node); var dataMw = DU.getDataMw(node);
var env = state.env; var env = state.env;
var html; var html;
@ -171,13 +170,11 @@ Ref.prototype.serialHandler = {
env.log('error', 'Ref body unavailable for: ' + node.outerHTML); env.log('error', 'Ref body unavailable for: ' + node.outerHTML);
return ''; // Drop it! return ''; // Drop it!
} }
return state.serializer.serializeHTML({ var src = yield state.serializer.serializeHTML({
env: state.env, env: state.env,
extName: dataMw.name, extName: dataMw.name,
}, html).then(function(src) { }, html);
return startTagSrc + src + '</' + dataMw.name + '>'; return startTagSrc + src + '</' + dataMw.name + '>';
});
});
}), }),
}; };
@ -664,29 +661,26 @@ References.prototype.insertMissingReferencesIntoDOM = function(refsData, node) {
}; };
References.prototype.serialHandler = { References.prototype.serialHandler = {
handle: Promise.method(function(node, state, wrapperUnmodified) { handle: Promise.async(function *(node, state, wrapperUnmodified) {
var dataMw = DU.getDataMw(node); var dataMw = DU.getDataMw(node);
if (dataMw.autoGenerated && state.rtTestMode) { if (dataMw.autoGenerated && state.rtTestMode) {
// Eliminate auto-inserted <references /> noise in rt-testing // Eliminate auto-inserted <references /> noise in rt-testing
return Promise.resolve(''); return '';
} else { } else {
return state.serializer.serializeExtensionStartTag(node, state) var startTagSrc = yield state.serializer.serializeExtensionStartTag(node, state);
.then(function(startTagSrc) {
if (!dataMw.body) { if (!dataMw.body) {
return startTagSrc; // We self-closed this already. return startTagSrc; // We self-closed this already.
} else if (typeof dataMw.body.html === 'string') { } else if (typeof dataMw.body.html === 'string') {
return state.serializer.serializeHTML({ var src = yield state.serializer.serializeHTML({
env: state.env, env: state.env,
extName: dataMw.name, extName: dataMw.name,
}, dataMw.body.html).then(function(src) { }, dataMw.body.html);
return startTagSrc + src + '</' + dataMw.name + '>'; return startTagSrc + src + '</' + dataMw.name + '>';
});
} else { } else {
state.env.log('error', state.env.log('error',
'References body unavailable for: ' + node.outerHTML); 'References body unavailable for: ' + node.outerHTML);
return ''; // Drop it! return ''; // Drop it!
} }
});
} }
}), }),
before: function(node, otherNode, state) { before: function(node, otherNode, state) {