You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hover over a link with the target="_blank" attribute (either add it in the
HTML source code, or add it by using MediumEditor) and click the URL popup
that appears to edit the link. The link I used is very simple: It contains
just one single, unformatted word.
In the URL edit form that opens, uncheck the "Open in new window" (make sure
that it is checked).
Click the checkmark in the URL edit form to confirm the changes.
In Firefox (Developer Edition 45.0a2 on Ubuntu 15.04 in my case), the target="_blank" attribute is still there. (I inspected the link with the
devtools to see it. You can also re-open the URL edit form and see that the
"Open link in new window" checkbox has been "re-checked"). In Chromium, target="_blank" is removed as expected when unchecking the checkbox.
When running the debugger, I found that this line was executed:
The code seems to rely on that running document.execCommand('createLink', false, url) returns a fresh link without a target attribute. That's the case
in Chromium, but not in Firefox.
I made a reduced test case that only uses that line of code to demonstrate what
happens.
Select the entire link with the mouse (the word "test").
Run the following code in the console while the link is selected:
document.execCommand('createLink',false,'/bar')
Inspect the link with the devtools. Notice how the href attribute has
changed from /foo to /bar, but the target="_blank" attribute remained.
In Firefox, that is. When doing the same in Chromium, the target attribute
vanishes (or, perhaps, isn't preserved, depending on how you look at it).
I suggest explicitly removing the target attribute to fix this problem.
The text was updated successfully, but these errors were encountered:
Thanks for pointing this out @lydell , if you have a chance to submit a fix for this we'd be glad to accept it, especially since you've been able to narrow down the code and describe an excellent test scenario.
Otherwise, hopefully I'll have some time to look into it or someone else might take a crack at fixing it 😄
Steps to reproduce in Firefox:
target="_blank"
attribute (either add it in theHTML source code, or add it by using MediumEditor) and click the URL popup
that appears to edit the link. The link I used is very simple: It contains
just one single, unformatted word.
that it is checked).
In Firefox (Developer Edition 45.0a2 on Ubuntu 15.04 in my case), the
target="_blank"
attribute is still there. (I inspected the link with thedevtools to see it. You can also re-open the URL edit form and see that the
"Open link in new window" checkbox has been "re-checked"). In Chromium,
target="_blank"
is removed as expected when unchecking the checkbox.When running the debugger, I found that this line was executed:
medium-editor/src/js/core.js
Line 1043 in f7c522a
The code seems to rely on that running
document.execCommand('createLink', false, url)
returns a fresh link without atarget
attribute. That's the casein Chromium, but not in Firefox.
I made a reduced test case that only uses that line of code to demonstrate what
happens.
Open the following page:
Select the entire link with the mouse (the word "test").
Run the following code in the console while the link is selected:
Inspect the link with the devtools. Notice how the
href
attribute haschanged from
/foo
to/bar
, but thetarget="_blank"
attribute remained.In Firefox, that is. When doing the same in Chromium, the
target
attributevanishes (or, perhaps, isn't preserved, depending on how you look at it).
I suggest explicitly removing the
target
attribute to fix this problem.The text was updated successfully, but these errors were encountered: