You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
View.style is not consistent with Declarative UI .style property. #619
If you look at the view-common.ts class; attempting to assign anything via JavaScript to the style property of the class, will throw a runtime error about the style being read only. However in the Declarative UI, you use the style property to assign a text style string to the component.
This is inconsistent, Anything I can do in the Declarative UI; should be equally do-able via JavaScript. Yes, I realize I can modify individual View.style.someProperty; but if I can use a String in the Declarative UI; I should be able to use a string via JavaScript.
I should be able to do view.style = "padding-left: 2; background-color: red" and get this applied. Just like if I put it in the Declarative UI XML.
I believe what needs to happen if I apply a inline style string to the style; that I need to reset the styles variable; re-apply App.css, then Page.css; then run the same code that is inside this._applyInlineStyle(inlineStyleString);. This way the style is reset back to scratch each time I apply a inline style string.
Any arguments against? If my position and assumptions on what needs to happen is correct, I can work on a commit patch later in the week...
Style property works very similar to HTML/JavaScript - in HTML/XML you can set the in-line string and in JavaScript you can manipulate directly the Style object using desired properties/methods. What we are missing in {N} is something similar to setAttribute where you can use the same syntax as in HTML/XML.
If we have this method you will be able to set in-line style like this:
In my opinion setAttribute is too generic. This would mean that user will be able to set other properties as well (not only style property). I believe that there should be only one way of doing things. This will give us smaller test surface, consistent API, less confusion.
Style setter is read-only on purpose - when using intellisense the chance to make error are smaller. Otherwise you have to pass string and run the app to check if the string you set is correct.
If there is a need to set Style from code as string it would be better to expose new method - setStyle(value: string).
Activity
enchev commentedon Aug 25, 2015
Hey @NathanaelA,
Very good question!
Style property works very similar to HTML/JavaScript - in HTML/XML you can set the in-line string and in JavaScript you can manipulate directly the Style object using desired properties/methods. What we are missing in {N} is something similar to setAttribute where you can use the same syntax as in HTML/XML.
If we have this method you will be able to set in-line style like this:
What do you think?
NathanaelA commentedon Aug 25, 2015
hshristov commentedon Aug 26, 2015
In my opinion setAttribute is too generic. This would mean that user will be able to set other properties as well (not only style property). I believe that there should be only one way of doing things. This will give us smaller test surface, consistent API, less confusion.
Style setter is read-only on purpose - when using intellisense the chance to make error are smaller. Otherwise you have to pass string and run the app to check if the string you set is correct.
If there is a need to set Style from code as string it would be better to expose new method - setStyle(value: string).
lock commentedon Aug 31, 2019
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.