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