Remove target=_self from commentlinks
When target=_self is used, the app is fully reloaded. When target is not
specified, it is opening in same tab as with target=_self, but page
loading is much faster, because it will go via internal navigation
without needing to fully reload the app.
Change-Id: Ibd0713992344a310976a4ee72a511790c8aff85d
(cherry picked from commit aa3f3a2998)
This commit is contained in:
committed by
David Pursehouse
parent
ff2ed9c01e
commit
4324bc57ba
@@ -71,10 +71,11 @@
|
||||
// Ensure that external links originating from HTML commentlink configs
|
||||
// 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
|
||||
// open in the same tab. When target is not set - default is _self
|
||||
// @see Issue 4616
|
||||
output.querySelectorAll('a').forEach(anchor => {
|
||||
if (anchor.hostname === window.location.hostname) {
|
||||
anchor.setAttribute('target', '_self');
|
||||
anchor.removeAttribute('target');
|
||||
} else {
|
||||
anchor.setAttribute('target', '_blank');
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ limitations under the License.
|
||||
const linkEl = element.$.output.childNodes[1];
|
||||
assert.equal(textNode.textContent, prefix);
|
||||
const url = '/q/' + changeID;
|
||||
assert.equal(linkEl.target, '_self');
|
||||
assert.isFalse(linkEl.hasAttribute('target'));
|
||||
// Since url is a path, the host is added automatically.
|
||||
assert.isTrue(linkEl.href.endsWith(url));
|
||||
assert.equal(linkEl.textContent, changeID);
|
||||
@@ -160,7 +160,7 @@ limitations under the License.
|
||||
const linkEl = element.$.output.childNodes[1];
|
||||
assert.equal(textNode.textContent, prefix);
|
||||
const url = '/r/q/' + changeID;
|
||||
assert.equal(linkEl.target, '_self');
|
||||
assert.isFalse(linkEl.hasAttribute('target'));
|
||||
// Since url is a path, the host is added automatically.
|
||||
assert.isTrue(linkEl.href.endsWith(url));
|
||||
assert.equal(linkEl.textContent, changeID);
|
||||
@@ -201,7 +201,7 @@ limitations under the License.
|
||||
|
||||
assert.equal(textNode.textContent, prefix);
|
||||
|
||||
assert.equal(changeLinkEl.target, '_self');
|
||||
assert.isFalse(changeLinkEl.hasAttribute('target'));
|
||||
assert.isTrue(changeLinkEl.href.endsWith(changeUrl));
|
||||
assert.equal(changeLinkEl.textContent, changeID);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user