DLynch has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/394373 )
Change subject: Use rel="noopener" on links targeted at new windows
......................................................................
Use rel="noopener" on links targeted at new windows
Bug: T180932
Change-Id: I9b7e32bf110e9a1b96b057242121b59b4c9c9513
---
M src/ui/contextitems/ve.ui.LinkContextItem.js
M src/ve.utils.js
M tests/ui/ve.ui.DiffElement.test.js
3 files changed, 5 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor
refs/changes/73/394373/1
diff --git a/src/ui/contextitems/ve.ui.LinkContextItem.js
b/src/ui/contextitems/ve.ui.LinkContextItem.js
index ffc3c06..3fb1c51 100644
--- a/src/ui/contextitems/ve.ui.LinkContextItem.js
+++ b/src/ui/contextitems/ve.ui.LinkContextItem.js
@@ -61,7 +61,8 @@
.text( this.getDescription() )
.attr( {
href: ve.resolveUrl( this.model.getHref(),
htmlDoc ),
- target: '_blank'
+ target: '_blank',
+ rel: 'noopener'
} )
);
};
diff --git a/src/ve.utils.js b/src/ve.utils.js
index 72eb3dc..c0d874c 100644
--- a/src/ve.utils.js
+++ b/src/ve.utils.js
@@ -1043,6 +1043,7 @@
ve.targetLinksToNewWindow = function ( container ) {
// Make all links open in a new window
Array.prototype.forEach.call( container.querySelectorAll( 'a[href]' ),
function ( el ) {
+ el.setAttribute( 'rel', 'noopener' );
el.setAttribute( 'target', '_blank' );
} );
};
diff --git a/tests/ui/ve.ui.DiffElement.test.js
b/tests/ui/ve.ui.DiffElement.test.js
index d8983a3..624888f 100644
--- a/tests/ui/ve.ui.DiffElement.test.js
+++ b/tests/ui/ve.ui.DiffElement.test.js
@@ -375,7 +375,7 @@
newDoc: '<p>foo <a
href="http://example.org/whee">bar</a> baz</p>',
expected:
'<div
class="ve-ui-diffElement-doc-child-change">' +
- '<p>foo <span
data-diff-action="change-remove"><a href="http://example.org/quuz"
target="_blank">bar</a></span><span data-diff-action="change-insert"
data-diff-id="0"><a href="http://example.org/whee"
target="_blank">bar</a></span> baz</p>' +
+ '<p>foo <span
data-diff-action="change-remove"><a href="http://example.org/quuz"
rel="noopener" target="_blank">bar</a></span><span
data-diff-action="change-insert" data-diff-id="0"><a
href="http://example.org/whee" rel="noopener" target="_blank">bar</a></span>
baz</p>' +
'</div>'
},
{
@@ -384,7 +384,7 @@
newDoc: '<p><a href="http://example.org/">foo
<b>bar</b> baz</a></p>',
expected:
'<div
class="ve-ui-diffElement-doc-child-change">' +
- '<p><a
href="http://example.org/" target="_blank">foo <del
data-diff-action="remove">bar</del><ins
data-diff-action="insert"><b>bar</b></ins> baz</a></p>' +
+ '<p><a
href="http://example.org/" rel="noopener" target="_blank">foo <del
data-diff-action="remove">bar</del><ins
data-diff-action="insert"><b>bar</b></ins> baz</a></p>' +
'</div>'
},
{
--
To view, visit https://gerrit.wikimedia.org/r/394373
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9b7e32bf110e9a1b96b057242121b59b4c9c9513
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: DLynch <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits