Safer DOM


License

License

MIT
GroupId

GroupId

org.danielnixon
ArtifactId

ArtifactId

safer-dom_sjs0.6_2.11
Last Version

Last Version

0.5.0
Release Date

Release Date

Type

Type

jar
Description

Description

Safer DOM
Safer DOM
Project URL

Project URL

https://github.com/danielnixon/safer-dom
Project Organization

Project Organization

org.danielnixon
Source Code Management

Source Code Management

https://github.com/danielnixon/safer-dom

Download safer-dom_sjs0.6_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/org.danielnixon/safer-dom_sjs0.6_2.11/ -->
<dependency>
    <groupId>org.danielnixon</groupId>
    <artifactId>safer-dom_sjs0.6_2.11</artifactId>
    <version>0.5.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.danielnixon/safer-dom_sjs0.6_2.11/
implementation 'org.danielnixon:safer-dom_sjs0.6_2.11:0.5.0'
// https://jarcasting.com/artifacts/org.danielnixon/safer-dom_sjs0.6_2.11/
implementation ("org.danielnixon:safer-dom_sjs0.6_2.11:0.5.0")
'org.danielnixon:safer-dom_sjs0.6_2.11:jar:0.5.0'
<dependency org="org.danielnixon" name="safer-dom_sjs0.6_2.11" rev="0.5.0">
  <artifact name="safer-dom_sjs0.6_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.danielnixon', module='safer-dom_sjs0.6_2.11', version='0.5.0')
)
libraryDependencies += "org.danielnixon" % "safer-dom_sjs0.6_2.11" % "0.5.0"
[org.danielnixon/safer-dom_sjs0.6_2.11 "0.5.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.11
org.scala-js : scalajs-library_2.11 jar 0.6.17
org.scala-js : scalajs-dom_sjs0.6_2.11 jar 0.9.2

test (1)

Group / Artifact Type Version
org.scala-js : scalajs-test-interface_2.11 jar 0.6.17

Project Modules

There are no modules declared in this project.

safer-dom

Build Status Maven Central

A scala-js-dom library that replaces nullable return types T (which the web APIs like to do everywhere) with Option[T].

Usage

  1. Add the dependency to your build:

libraryDependencies += "org.danielnixon" %%% "safer-dom" % "0.4.0"

  1. Import org.danielnixon.saferdom.implicits._.

  2. Replace calls to nullable methods (e.g. document.querySelector()) with their safer alternatives (e.g. document.querySelectorOpt()).

For example, this (which would have exploded with a TypeError at runtime):

window.document.querySelector("nope").innerHTML = "foo"

can be now be written as:

import org.danielnixon.saferdom.implicits._
window.document.querySelectorOpt("nope").foreach(_.innerHTML = "foo")

Versions

Version
0.5.0
0.4.0
0.3.0
0.2
0.1