mirror of
https://github.com/documentationjs/documentation.git
synced 2026-01-18 14:17:30 +00:00
Fix linkerStack resolution order (#564)
This commit is contained in:
parent
145c199a68
commit
7ccf89d83c
@ -43,7 +43,7 @@ function LinkerStack(config) {
|
||||
this.stack = [];
|
||||
|
||||
if (config.defaultGlobals !== false) {
|
||||
this.stack.push(function (namespace) {
|
||||
this.stack.unshift(function (namespace) {
|
||||
if (namespace) {
|
||||
return globalsDocs.getDoc(namespace, config.defaultGlobalsEnvs);
|
||||
}
|
||||
@ -51,7 +51,7 @@ function LinkerStack(config) {
|
||||
}
|
||||
|
||||
if (config.paths) {
|
||||
this.stack.push(pathsLinker(config.paths));
|
||||
this.stack.unshift(pathsLinker(config.paths));
|
||||
}
|
||||
|
||||
this.link = this.link.bind(this);
|
||||
@ -84,7 +84,7 @@ LinkerStack.prototype.namespaceResolver = function (comments, resolver) {
|
||||
walk(comments, function (comment) {
|
||||
namespaces[comment.namespace] = true;
|
||||
});
|
||||
this.stack.push(function (namespace) {
|
||||
this.stack.unshift(function (namespace) {
|
||||
if (namespaces[namespace] === true) {
|
||||
return resolver(namespace);
|
||||
}
|
||||
|
||||
@ -17,5 +17,31 @@ test('linkerStack', function (t) {
|
||||
'http://geojson.org/geojson-spec.html#point',
|
||||
'Custom hardcoded path for a GeoJSON type');
|
||||
|
||||
|
||||
t.equal(createLinkerStack({
|
||||
paths: {
|
||||
Image: 'http://custom.com/'
|
||||
}
|
||||
}).link('Image'),
|
||||
'http://custom.com/',
|
||||
'Prefers config link to native.');
|
||||
|
||||
|
||||
var linker = createLinkerStack({
|
||||
paths: {
|
||||
Image: 'http://custom.com/'
|
||||
}
|
||||
});
|
||||
|
||||
linker.namespaceResolver([{
|
||||
namespace: 'Image',
|
||||
}], function (namespace) {
|
||||
return '#' + namespace;
|
||||
});
|
||||
|
||||
t.equal(linker.link('Image'),
|
||||
'#Image',
|
||||
'Prefers local link over all.');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user