-
23 Sep 2009 4:49 AM #1
Unanswered: jQuery: $('#message').text("Howdy"); ?
Unanswered: jQuery: $('#message').text("Howdy"); ?
Isn't there an easy way to quickly create a single text node children of a matched element (removing any other child elements before)?
-
23 Sep 2009 5:10 AM #2Sencha - Ext JS Dev Team
- Join Date
- Mar 2007
- Location
- Notts/Redwood City
- Posts
- 30,458
- Vote Rating
- 20
- Answers
- 9
Code:Ext.get("message").update("howdy");Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
23 Sep 2009 5:20 AM #3
Thanks, indeed I missed that.
However isn't Element.update() a potential attack vector for XSS?
jQuery's text() function is much safer as it will only ever create a text node.
-
23 Sep 2009 5:38 AM #4Sencha - Ext JS Dev Team
- Join Date
- Mar 2007
- Location
- Notts/Redwood City
- Posts
- 30,458
- Vote Rating
- 20
- Answers
- 9
Well!
ThenCode:Ext.override(Ext.Element, { text: function(t) { this.dom.innerHTML = ''; this.dom.appendChild(document.createTextNode(t)); } });
Code:Ext.get("message").text("howdy");Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
22 Oct 2009 12:28 PM #5
seems like a lot of things that should be in core have to be added in via the override. Kind of defeats have the core if its size is doubled just to bring in some basic stuff.
Animal, can't you just combine all the overrides you have posted in here and submit it to be added in a future release?
-
23 Oct 2009 11:05 AM #6Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Haarlem, Netherlands
- Posts
- 1,235
- Vote Rating
- 4
- Answers
- 28
The purpose of update() is to just to prevent having to use dom.innerHTML.
The argument that it would cause XSS vulnerabilities is non-valid since you have to prevent XSS attacks on the serverside by making sure the data is safe before you even send it back to the clientside. Trying to do security on the client-side is a lost cause. It means your already too late into the game to try and do anything seriously helpful.
Anyway, we will internally discuss if we should put the .text() method in. Its not too many bytes, and if it would help a lot of people then its definitely worth it. I've done many coding with Ext Core though, and I had never ever had a need for it. Really because you can use update() for both text and HTML!
-
24 Oct 2009 12:49 AM #7Sencha - Ext JS Dev Team
- Join Date
- Mar 2007
- Location
- Notts/Redwood City
- Posts
- 30,458
- Vote Rating
- 20
- Answers
- 9
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
26 Oct 2009 10:22 AM #8
Does update() both get the text and set it? Does it work on input fields?
I just did a quick search to try and find the docs for update() but either I don't know where to look or its not easy to find. Where would I go to find that? API search didn't work, Google didn't work unless its buried.
-
26 Oct 2009 10:32 PM #9Sencha - Ext JS Dev Team
- Join Date
- Mar 2007
- Location
- Notts/Redwood City
- Posts
- 30,458
- Vote Rating
- 20
- Answers
- 9
You can't find it because it's not there.
I just linked to a post where I showed you how to ADD it.Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642


Reply With Quote


