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 dest, nameTreeRef, nameDictionaryRef;
|
||||
var dest = null, nameTreeRef, nameDictionaryRef;
|
||||
var obj = this.catDict.get('Names');
|
||||
if (obj && obj.has('Dests')) {
|
||||
nameTreeRef = obj.getRaw('Dests');
|
||||
@ -493,17 +493,11 @@ var Catalog = (function CatalogClosure() {
|
||||
nameDictionaryRef = this.catDict.get('Dests');
|
||||
}
|
||||
|
||||
if (nameDictionaryRef) {
|
||||
// reading simple destination dictionary
|
||||
obj = nameDictionaryRef;
|
||||
obj.forEach(function catalogForEach(key, value) {
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
if (key === destinationId) {
|
||||
if (nameDictionaryRef) { // Simple destination dictionary.
|
||||
var value = nameDictionaryRef.get(destinationId);
|
||||
if (value) {
|
||||
dest = fetchDestination(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (nameTreeRef) {
|
||||
var nameTree = new NameTree(nameTreeRef, xref);
|
||||
|
@ -129,6 +129,12 @@ describe('api', function() {
|
||||
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() {
|
||||
var promise = doc.getAttachments();
|
||||
waitsForPromiseResolved(promise, function (data) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user