Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

NgModelController demo fix for html injection into contenteditable directive #3156

Closed
wants to merge 1 commit into from
Closed

Conversation

michaeltaranto
Copy link

The 'contenteditable' div and the textarea should be passing their text values between each other not their escaped inner html. This breaks the demo as the 'required' class is not applied when the 'contenteditable' div is cleared.

…rective

The 'contenteditable' div and the textarea should be passing their text values between each other not their escaped inner html. This breaks the demo as the 'required' class is not applied when the 'contenteditable' div is cleared.
@petebacondarwin
Copy link
Contributor

@mjt01 - This is not really correct.
In this example, the <textarea> shows the raw HTML whereas the contenteditable <div> is showing the rendered HTML. This allows us to put things like <strong>Hello</strong> into the <textarea>, which will be displayed in bold in the <div>. Also you can do things like hit Ctrl-I in the <div> and the selected text will be wrapped in a <em> in the textarea.

The problem you are describing is caused because if you clear the <div>, the browser actually leaves a <br> in as its content, which is not shown in the div but stops the directive from being empty.

How about we strip this <br>: http://plnkr.co/edit/UzDXIvESMk6PsotFTEDs?p=preview

petebacondarwin added a commit that referenced this pull request Jul 8, 2013
The example directive, using contenteditable was not showing required
even if you cleared the content from it.

Closes #3156
@michaeltaranto michaeltaranto deleted the patch-1 branch July 9, 2013 11:12
@michaeltaranto
Copy link
Author

Thanks Pete. Sorry to be honest a colleague pointed me at this and the way it was explained it sounded like the use of html injection was a problem rather than the actual requirement.

Yes I agree with your patch to strip the br tag when the returned html is blank. Thanks for your fast review.

ctrahey pushed a commit to ctrahey/angular.js that referenced this pull request Jul 22, 2013
The example directive, using contenteditable was not showing required
even if you cleared the content from it.

Closes angular#3156
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants