Bug Tracker

Modify

Ticket #443 (closed enhancement: invalid)

Opened 7 years ago

Last modified 7 years ago

SPAM

Reported by: joern Owned by:
Priority: minor Milestone:
Component: core Version: 1.1a
Keywords: Cc:
Blocking: Blocked by:

Description (last modified by joern) (diff)

Take this example:

html = "<ul><li>...</li></ul>";
html = $(html).find("li").css("color", "red").html();

It should be possible to write this as:

html = $("li", html).css("color", "red").html();

Change History

comment:1 Changed 7 years ago by Johan

Good point, you'd want to correct the html example just to be clear though. ( html = "<ul><li>...</li></ul>"; )

comment:2 Changed 7 years ago by anonymous

Well, I would change this behaviour:

$('li'). css("color","red") changes the DOM tree automatically

$('li',html).css("color","red") should also change the html-code automatically.

comment:3 Changed 7 years ago by Dave

I need some clarification on the semantics. In $("li", html) only the li elements are selected, right? So (with Johan's correction) there is a ul parent that binds them all and can be reached through parent() in later chained methods. What about the situation where the html fragment defines multiple sibling nodes that have no parent, and the selector doesn't grab them all?

html = "<p>test</p><div>one</div><p>two</p><p>three</p>"
$("div", html);

It seems like an html string with a single root context node is probably easy to implement by running it through jQuery.clean. But I am not sure what is supposed to happen when there are multiple nodes in the context.

comment:4 Changed 7 years ago by joern

   $('li',html).css("color","red") should also change the html-code automatically.

Strings are immutable in javascript, therefore the html-code must be retrieved if needed.

Dave: It doesn't work.

comment:5 Changed 7 years ago by joern

  • Description modified (diff)

comment:6 Changed 7 years ago by anonymous

  • Status changed from new to reopened

comment:7 Changed 7 years ago by joern

  • Status changed from reopened to closed
  • Resolution set to invalid

comment:8 Changed 7 years ago by anonymous

  • Status changed from closed to reopened
  • Resolution invalid deleted

comment:9 Changed 7 years ago by brandon

  • Status changed from reopened to closed
  • Resolution set to invalid
  • Summary changed from Accept html markup as context paramter to jQuery constructor to SPAM

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.