YUI2's Dom.get accepts both a DOM element or an id string as a parameter. In YUI3, Y.one is the replacement for Dom.get but it only accepts CSS selectors, not DOM elements. Is there a simple way, using YUI3, to normalise a JavaScript object to a DOM element?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
According to the API docs for Y.one it does accept a DOM element.
I think you can also pass a YUI 3 Node to it too. The only thing it doesn't do that DOM.get did is accept an id that isn't a CSS selector (e.g. 'foo' instead of '#foo').
To support the same signature as
YAHOO.util.Dom.get
you could do something like this:Here's an example of the function above in use.