From 038f0af68fcd0cfa034eed4b32c2ac0f6adc544e Mon Sep 17 00:00:00 2001 From: James Strachan Date: Tue, 3 Jul 2012 20:14:13 +0100 Subject: [PATCH] fixed failing test case, so we can use the browser API from JVM code and at least have an empty document to play with --- .../stdlib/src/kotlin/browser/Properties.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libraries/stdlib/src/kotlin/browser/Properties.kt b/libraries/stdlib/src/kotlin/browser/Properties.kt index 0554c6d04ed..ba02ef8c997 100644 --- a/libraries/stdlib/src/kotlin/browser/Properties.kt +++ b/libraries/stdlib/src/kotlin/browser/Properties.kt @@ -1,7 +1,7 @@ package kotlin.browser -import org.w3c.dom.Document import js.native +import org.w3c.dom.Document private var _document: Document? = null @@ -9,7 +9,13 @@ private var _document: Document? = null * Provides access to the current active browsers DOM for the currently visible page. */ native public var document: Document - get() = _document!! - set(value) { - _document = value - } \ No newline at end of file + get() { + // Note this code is only executed on the JVM + val answer = _document + return if (answer == null) { + kotlin.dom.createDocument() + } else answer + } + set(value) { + _document = value + }