Last active
December 17, 2015 13:10
-
-
Save joliss/5615156 to your computer and use it in GitHub Desktop.
This is untested.
This file contains 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
Em.View.reopen | |
classNameBindings: ['testingClass'] | |
testingClass: (-> | |
if Em.testing | |
if testingClass = this.valueBinding?._from?.match(/[\w|\d]+\.[\w|\d]+$/)?[0] | |
testingClass.replace('context.', '').replace('.', '__') | |
).property() |
One problem is, subclasses might override classNameBindings
and thereby kill the testingClass
. Reopening (monkey-patching) base-classes like this is generally a bit icky, because it causes these kinds of problems.
Thx, @joliss! I forgot that classNames
is concatenated property =)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This exploits the fact that if the function returns false (or null/undefined presumably), the class will simply not be inserted. http://emberjs.com/api/classes/Ember.View.html