Merge "Open relative commentlinks in same tab" into stable-2.16
This commit is contained in:
@@ -68,10 +68,16 @@
|
|||||||
this._handleParseResult.bind(this), this.removeZeroWidthSpace);
|
this._handleParseResult.bind(this), this.removeZeroWidthSpace);
|
||||||
parser.parse(content);
|
parser.parse(content);
|
||||||
|
|
||||||
// Ensure that links originating from HTML commentlink configs open in a
|
// Ensure that external links originating from HTML commentlink configs
|
||||||
// new tab. @see Issue 5567
|
// open in a new tab. @see Issue 5567
|
||||||
|
// Ensure links to the same host originating from commentlink configs
|
||||||
|
// open in the same tab. @see Issue 4616
|
||||||
output.querySelectorAll('a').forEach(anchor => {
|
output.querySelectorAll('a').forEach(anchor => {
|
||||||
anchor.setAttribute('target', '_blank');
|
if (anchor.hostname === window.location.hostname) {
|
||||||
|
anchor.setAttribute('target', '_self');
|
||||||
|
} else {
|
||||||
|
anchor.setAttribute('target', '_blank');
|
||||||
|
}
|
||||||
anchor.setAttribute('rel', 'noopener');
|
anchor.setAttribute('rel', 'noopener');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@@ -142,7 +142,7 @@ limitations under the License.
|
|||||||
const linkEl = element.$.output.childNodes[1];
|
const linkEl = element.$.output.childNodes[1];
|
||||||
assert.equal(textNode.textContent, prefix);
|
assert.equal(textNode.textContent, prefix);
|
||||||
const url = '/q/' + changeID;
|
const url = '/q/' + changeID;
|
||||||
assert.equal(linkEl.target, '_blank');
|
assert.equal(linkEl.target, '_self');
|
||||||
// Since url is a path, the host is added automatically.
|
// Since url is a path, the host is added automatically.
|
||||||
assert.isTrue(linkEl.href.endsWith(url));
|
assert.isTrue(linkEl.href.endsWith(url));
|
||||||
assert.equal(linkEl.textContent, changeID);
|
assert.equal(linkEl.textContent, changeID);
|
||||||
@@ -160,7 +160,7 @@ limitations under the License.
|
|||||||
const linkEl = element.$.output.childNodes[1];
|
const linkEl = element.$.output.childNodes[1];
|
||||||
assert.equal(textNode.textContent, prefix);
|
assert.equal(textNode.textContent, prefix);
|
||||||
const url = '/r/q/' + changeID;
|
const url = '/r/q/' + changeID;
|
||||||
assert.equal(linkEl.target, '_blank');
|
assert.equal(linkEl.target, '_self');
|
||||||
// Since url is a path, the host is added automatically.
|
// Since url is a path, the host is added automatically.
|
||||||
assert.isTrue(linkEl.href.endsWith(url));
|
assert.isTrue(linkEl.href.endsWith(url));
|
||||||
assert.equal(linkEl.textContent, changeID);
|
assert.equal(linkEl.textContent, changeID);
|
||||||
@@ -201,7 +201,7 @@ limitations under the License.
|
|||||||
|
|
||||||
assert.equal(textNode.textContent, prefix);
|
assert.equal(textNode.textContent, prefix);
|
||||||
|
|
||||||
assert.equal(changeLinkEl.target, '_blank');
|
assert.equal(changeLinkEl.target, '_self');
|
||||||
assert.isTrue(changeLinkEl.href.endsWith(changeUrl));
|
assert.isTrue(changeLinkEl.href.endsWith(changeUrl));
|
||||||
assert.equal(changeLinkEl.textContent, changeID);
|
assert.equal(changeLinkEl.textContent, changeID);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user