Merge pull request #6187 from Snuffleupagus/more-efficient-getDestination
A couple of improvements of `getDestination` (unit-test included)
This commit is contained in:
commit
1416a1b521
@ -485,7 +485,7 @@ var Catalog = (function CatalogClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var xref = this.xref;
|
var xref = this.xref;
|
||||||
var dest, nameTreeRef, nameDictionaryRef;
|
var dest = null, nameTreeRef, nameDictionaryRef;
|
||||||
var obj = this.catDict.get('Names');
|
var obj = this.catDict.get('Names');
|
||||||
if (obj && obj.has('Dests')) {
|
if (obj && obj.has('Dests')) {
|
||||||
nameTreeRef = obj.getRaw('Dests');
|
nameTreeRef = obj.getRaw('Dests');
|
||||||
@ -493,17 +493,11 @@ var Catalog = (function CatalogClosure() {
|
|||||||
nameDictionaryRef = this.catDict.get('Dests');
|
nameDictionaryRef = this.catDict.get('Dests');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nameDictionaryRef) {
|
if (nameDictionaryRef) { // Simple destination dictionary.
|
||||||
// reading simple destination dictionary
|
var value = nameDictionaryRef.get(destinationId);
|
||||||
obj = nameDictionaryRef;
|
if (value) {
|
||||||
obj.forEach(function catalogForEach(key, value) {
|
dest = fetchDestination(value);
|
||||||
if (!value) {
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (key === destinationId) {
|
|
||||||
dest = fetchDestination(value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (nameTreeRef) {
|
if (nameTreeRef) {
|
||||||
var nameTree = new NameTree(nameTreeRef, xref);
|
var nameTree = new NameTree(nameTreeRef, xref);
|
||||||
|
@ -129,6 +129,12 @@ describe('api', function() {
|
|||||||
0, 841.89, null]);
|
0, 841.89, null]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it('gets a non-existent destination', function() {
|
||||||
|
var promise = doc.getDestination('non-existent-named-destination');
|
||||||
|
waitsForPromiseResolved(promise, function(data) {
|
||||||
|
expect(data).toEqual(null);
|
||||||
|
});
|
||||||
|
});
|
||||||
it('gets attachments', function() {
|
it('gets attachments', function() {
|
||||||
var promise = doc.getAttachments();
|
var promise = doc.getAttachments();
|
||||||
waitsForPromiseResolved(promise, function (data) {
|
waitsForPromiseResolved(promise, function (data) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user