Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#36783 closed defect (bug) (fixed)

wplink should prioritize textContent over innerText so as to ignore any text-transform styling

Reported by: dougwollison's profile dougwollison Owned by: azaozz's profile azaozz
Milestone: 4.6 Priority: normal
Severity: normal Version:
Component: Editor Keywords:
Focuses: ui, javascript Cc:


On numerous sites we add button styles that use all-caps text. For SEO purposes, we don't literally make the text all-caps and have CSS ensure it's that way via text-transform.

However, in wplink, the text content of the link will be pulled in all-caps form when editing the link. This is due to this line in wp-includes/js/wplink.js:

linkText = linkNode.innerText || linkNode.textContent;

Based on how the tinyMCE plugin works, it should be safe to swap those priorities around:

linkText = linkNode.textContent || linkNode.innerText;

I've done a quick test on a site and it pulls the real, untransformed text; though I'd imagine it needs further testing; but I'm pretty sure old IE will fallback properly to innerText, which if I'm not mistaken is handled like the new textContent would.

Attachments (1)

36783.diff (507 bytes) - added by dougwollison 8 years ago.
Reorders priority for linkText assignment

Download all attachments as: .zip

Change History (4)

8 years ago

Reorders priority for linkText assignment

#1 @azaozz
8 years ago

  • Milestone changed from Awaiting Review to 4.6

Makes sense.

#2 @azaozz
8 years ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In 37621:

Editor wpLink: swap the order of innerText and textContent to avoid getting styled text in IE.

Props dougwollison.
Fixes #36783.

#3 @iseulde
8 years ago

  • Version trunk deleted

Maybe it's worth adding a comment for the future?

Note: See TracTickets for help on using tickets.