Permalink
Browse files

Moved ExtendedElement out of dom

  • Loading branch information...
darkfrog26 committed Nov 1, 2018
1 parent b5154a6 commit bb1072640cb1037a905afc1d1ae88c3ee7b0f3eb
Showing with 17 additions and 14 deletions.
  1. +17 −0 dom/src/main/scala/io/youi/ExtendedElement.scala
  2. +0 −14 dom/src/main/scala/io/youi/dom.scala
@@ -0,0 +1,17 @@
package io.youi
import org.scalajs.dom.Element
class ExtendedElement(element: Option[Element]) {
def byTag[T <: Element](tagName: String): Vector[T] = bySelector[T](tagName)
def oneByTag[T <: Element](tagName: String): T = oneBySelector[T](tagName)
def byClass[T <: Element](className: String): Vector[T] = bySelector[T](s".$className")
def oneByClass[T <: Element](className: String): T = oneBySelector[T](s".$className")
def byName[T <: Element](name: String): Vector[T] = bySelector[T](s"""[name="$name"]""")
def oneByName[T <: Element](name: String): T = oneBySelector[T](s"""[name="$name"]""")
def getById[T <: Element](id: String): Option[T] = firstBySelector[T](s"#$id")
def byId[T <: Element](id: String): T = oneBySelector[T](s"#$id")
def bySelector[T <: Element](selectors: String): Vector[T] = dom.bySelector[T](selectors, element)
def firstBySelector[T <: Element](selectors: String): Option[T] = dom.firstBySelector[T](selectors, element)
def oneBySelector[T <: Element](selectors: String): T = dom.oneBySelector[T](selectors, element)
}
@@ -143,18 +143,4 @@ object dom extends ExtendedElement(None) {
}
}
}
}
class ExtendedElement(element: Option[Element]) {
def byTag[T <: Element](tagName: String): Vector[T] = bySelector[T](tagName)
def oneByTag[T <: Element](tagName: String): T = oneBySelector[T](tagName)
def byClass[T <: Element](className: String): Vector[T] = bySelector[T](s".$className")
def oneByClass[T <: Element](className: String): T = oneBySelector[T](s".$className")
def byName[T <: Element](name: String): Vector[T] = bySelector[T](s"""[name="$name"]""")
def oneByName[T <: Element](name: String): T = oneBySelector[T](s"""[name="$name"]""")
def getById[T <: Element](id: String): Option[T] = firstBySelector[T](s"#$id")
def byId[T <: Element](id: String): T = oneBySelector[T](s"#$id")
def bySelector[T <: Element](selectors: String): Vector[T] = dom.bySelector[T](selectors, element)
def firstBySelector[T <: Element](selectors: String): Option[T] = dom.firstBySelector[T](selectors, element)
def oneBySelector[T <: Element](selectors: String): T = dom.oneBySelector[T](selectors, element)
}

0 comments on commit bb10726

Please sign in to comment.