Currently mw.util.addPortlet() when used by gadgets creates an undetached portlet element. Since mw.util.addPortletLink() does not work on detached nodes, the DOM node must be appended beforehand.
Having knowledge of where the element is in the DOM would help in the implementation of T342815 as it would allow skins which have different types of menu to deduce what type the new menu should be.
TODO
- A second parameter is proposed that states a preferred location for the new menu e.g. mw.util.addPortlet( 'p-twinkle', 'Twinkle', '#p-cactions' )
- The parameter results in the element being appended in the DOM.
- The selector should be passed to the existing util.addPortlet hook so skins can use it to determine type.
- If a selector is passed the method should return null rather than the detached DOM node to avoid unexpected side effects from caller trying to add it somewhere else directly afterwards.