diff --git a/surreal.js b/surreal.js index b3e926b..00b6220 100644 --- a/surreal.js +++ b/surreal.js @@ -36,37 +36,65 @@ var $ = { // You can use a different name than "$", but you must change the refe e.attributes = e.attribute e.attr = e.attribute + // Tree Traversal. + e.el = (selector, start = e, warning = true) => $.el(selector, start, warning) + e.any = (selector, start = e, warning = true) => $.any(selector, start, warning) + Object.defineProperty(e, 'parent', { + get: () => $.sugar(e.parentElement), + configurable: true + }) + + // Add all plugin sugar. $._e = e // Plugin access to "e" for chaining. - for (const [key, value] of Object.entries(sugars)) { + for (const [key, value] of Object.entries($.sugars)) { e[key] = value.bind($) //e[key] = value } return e }, - // Return single element. Selector not needed if used with inline + // // - me(selector=null, start=document, warning=true) { - if (selector == null) return $.sugar(start.currentScript.parentElement) // Just local me() in