diff --git a/formats/link.js b/formats/link.js index 84deebc573..bacb777ee6 100644 --- a/formats/link.js +++ b/formats/link.js @@ -6,6 +6,7 @@ class Link extends Inline { let node = super.create(value); value = this.sanitize(value); node.setAttribute('href', value); + node.setAttribute('rel', 'noopener noreferrer'); node.setAttribute('target', '_blank'); return node; } diff --git a/test/unit/formats/link.js b/test/unit/formats/link.js index 0762d6594e..c37f815c00 100644 --- a/test/unit/formats/link.js +++ b/test/unit/formats/link.js @@ -12,7 +12,7 @@ describe('Link', function() { .insert('12', { link: 'https://quilljs.com' }) .insert('3\n') ); - expect(editor.scroll.domNode).toEqualHTML('

0123

'); + expect(editor.scroll.domNode).toEqualHTML('

0123

'); }); it('add invalid', function() { @@ -33,22 +33,22 @@ describe('Link', function() { .insert('12', { link: Link.SANITIZED_URL }) .insert('3\n') ); - expect(editor.scroll.domNode).toEqualHTML('

0123

'); + expect(editor.scroll.domNode).toEqualHTML('

0123

'); }); it('change', function() { - let editor = this.initialize(Editor, '

0123

'); + let editor = this.initialize(Editor, '

0123

'); editor.formatText(1, 2, { link: 'https://quilljs.com' }); expect(editor.getDelta()).toEqual(new Delta() .insert('0') .insert('12', { link: 'https://quilljs.com' }) .insert('3\n') ); - expect(editor.scroll.domNode).toEqualHTML('

0123

'); + expect(editor.scroll.domNode).toEqualHTML('

0123

'); }); it('remove', function() { - let editor = this.initialize(Editor, '

0123

'); + let editor = this.initialize(Editor, '

0123

'); editor.formatText(1, 2, { link: false }); let delta = new Delta().insert('0').insert('12', { size: 'large' }).insert('3\n'); expect(editor.getDelta()).toEqual(delta);