This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix($compile): fix ng-prop-* with undefined values #16798
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 tasks
gkalpak
suggested changes
Dec 22, 2018
var element = $compile('<span ng-prop-text="myText" />')($rootScope); | ||
// Initialze to non-falsey | ||
$rootScope.myText = 'abc'; | ||
$rootScope.$digest(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I like to say, you can make these shorter with: $rootScope.$apply('text = ...')
😁
gkalpak
reviewed
Dec 27, 2018
gkalpak
approved these changes
Dec 30, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Might be worth adding a test to ensure that values do not go through .prop()
or that special property names (such as class
) are not handled specially.
I've added 2 tests: 8b9cb92 |
mgol
approved these changes
Dec 30, 2018
jbedard
commented
Dec 30, 2018
@@ -3837,7 +3837,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { | |||
pre: function ngPropPreLinkFn(scope, $element) { | |||
function applyPropValue() { | |||
var propValue = ngPropGetter(scope); | |||
$element.prop(propName, sanitizer(propValue)); | |||
$element[0][propName] = sanitizer(propValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$element
can only ever have 1 element at this point, right? 😟
petebacondarwin
approved these changes
Jan 2, 2019
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #16797