Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support text in textarea elements #24

Open
skhavari opened this issue Oct 29, 2014 · 4 comments
Open

support text in textarea elements #24

skhavari opened this issue Oct 29, 2014 · 4 comments
Milestone

Comments

@skhavari
Copy link

Repro

  • append <textarea>lorem ipsum</textarea> to the demo contents
  • then search for lorem

Expect

  • lorem in the text area to by styled

Actual

  • lorem in the text area vanishes
@padolsey
Copy link
Owner

padolsey commented Nov 2, 2014

This is probably a legit issue, but I'm not sure how it should be fixed, or what the desirable behaviour is. Textarea inner-text (its value) is not interpreted as HTML so there's no actual way to style 'lorem' in your case (e.g. you could not wrap it in a custom <span> for example).

The correct behaviour is probably to entirely ignore anything within a <textarea> OR to allow replacement but with the knowledge that it'll only be able to replace the found string with another string (so replacing 'lorum', in your example, with 'foo', would work).

@skhavari
Copy link
Author

skhavari commented Nov 2, 2014

at minimum the inner-text of the textarea shouldn't be modified. currently text that match in the textarea vanishes.

@padolsey
Copy link
Owner

padolsey commented Nov 2, 2014

I agree.

FWIW, for now, you can use filterElements to avoid the textarea:

findAndReplaceDOMText(elementToSearchIn, {
  find: /lorem/,
  wrap: 'em',
  filterElements: function(node) {
    return node.nodeName.toLowerCase() !== 'textarea';
  }
});

@brettz9
Copy link

brettz9 commented Feb 12, 2015

Then there might be the issue of contenteditable textarea's (or contenteditable elements of any kind) which could reasonably allow the element wrapping...

@padolsey padolsey added this to the 1.0.0 milestone Dec 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants