aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields/URLField.ts
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-05-20 00:09:47 -0400
committerTyler Schicke <tyler_schicke@brown.edu>2019-05-20 00:09:47 -0400
commitaf2346983eae1145167b70faf96a9aec0ca82427 (patch)
tree36f89aeaaf335f0d12fd690592556d831162a59c /src/new_fields/URLField.ts
parentfa602aa4dec7b39b48779ffe907229db4d9f6264 (diff)
Fixed a bunch of demo bugs
Moved Field Symbols to separate file Editing is mostly working in debug viewer
Diffstat (limited to 'src/new_fields/URLField.ts')
-rw-r--r--src/new_fields/URLField.ts9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/new_fields/URLField.ts b/src/new_fields/URLField.ts
index d00a95a16..a6f8f1cc5 100644
--- a/src/new_fields/URLField.ts
+++ b/src/new_fields/URLField.ts
@@ -1,6 +1,7 @@
import { Deserializable } from "../client/util/SerializationHelper";
import { serializable, custom } from "serializr";
-import { ObjectField, Copy } from "./ObjectField";
+import { ObjectField } from "./ObjectField";
+import { ToScriptString, Copy } from "./FieldSymbols";
function url() {
return custom(
@@ -13,7 +14,7 @@ function url() {
);
}
-export class URLField extends ObjectField {
+export abstract class URLField extends ObjectField {
@serializable(url())
readonly url: URL;
@@ -22,6 +23,10 @@ export class URLField extends ObjectField {
this.url = url;
}
+ [ToScriptString]() {
+ return `new ${this.constructor.name}(new URL(${this.url.href}))`;
+ }
+
[Copy](): this {
return new (this.constructor as any)(this.url);
}