@expressen/tallahassee
Advanced tools
Comparing version 14.10.3 to 14.11.0
@@ -24,2 +24,3 @@ "use strict"; | ||
const kElementFactory = Symbol.for("element factory"); | ||
const kActiveElement = Symbol.for("activeElement"); | ||
@@ -63,2 +64,5 @@ module.exports = class Document extends Node { | ||
} | ||
get activeElement() { | ||
return this[kActiveElement] || this.body; | ||
} | ||
get firstElementChild() { | ||
@@ -167,2 +171,5 @@ return this.documentElement; | ||
} | ||
_setActiveElement(element) { | ||
this[kActiveElement] = element; | ||
} | ||
_getElement($elm) { | ||
@@ -169,0 +176,0 @@ const $ = this[kDollar]; |
@@ -7,3 +7,3 @@ "use strict"; | ||
const { DOCUMENT_FRAGMENT_NODE, TEXT_NODE } = require("./nodeTypes.js"); | ||
const { Event, PointerEvent } = require("./Events.js"); | ||
const { Event } = require("./Events.js"); | ||
const { getElementsByClassName, getElementsByTagName } = require("./getElements.js"); | ||
@@ -258,10 +258,2 @@ const Attr = require("./Attr.js"); | ||
} | ||
click() { | ||
if (this.disabled) return; | ||
if (this.nodeName === "SUMMARY") { | ||
this.closest("details").open = !this.closest("details").open; | ||
} | ||
this.dispatchEvent(new PointerEvent("click", { bubbles: true })); | ||
} | ||
closest(selector) { | ||
@@ -268,0 +260,0 @@ return this._getElement(this.$elm.closest(selector)); |
@@ -77,2 +77,10 @@ "use strict"; | ||
class FocusEvent extends UIEvent { | ||
constructor(type, options = {}) { | ||
super(type, { bubbles: true }); | ||
this.relatedTarget = options.relatedTarget || null; | ||
} | ||
} | ||
class InputEvent extends UIEvent { | ||
@@ -100,2 +108,3 @@ constructor(type) { | ||
InputEvent, | ||
FocusEvent, | ||
PointerEvent, | ||
@@ -102,0 +111,0 @@ SubmitEvent, |
"use strict"; | ||
const { PointerEvent } = require("./Events.js"); | ||
const HTMLElement = require("./HTMLElement.js"); | ||
@@ -47,8 +46,2 @@ | ||
} | ||
click() { | ||
if (this.disabled) return; | ||
const clickEvent = new PointerEvent("click", { bubbles: true }); | ||
this.dispatchEvent(clickEvent); | ||
} | ||
}; |
@@ -5,4 +5,5 @@ "use strict"; | ||
const DOMStringMap = require("./DOMStringMap.js"); | ||
const { Event } = require("./Events.js"); | ||
const { FocusEvent, PointerEvent } = require("./Events.js"); | ||
const documentSymbol = Symbol.for("document"); | ||
const datasetSymbol = Symbol.for("dataset"); | ||
@@ -14,2 +15,3 @@ | ||
this[documentSymbol] = document; | ||
this[datasetSymbol] = new DOMStringMap(this); | ||
@@ -20,11 +22,29 @@ } | ||
if (this.disabled) return; | ||
const focusEvent = new Event("focus", { bubbles: true }); | ||
const doc = this[documentSymbol]; | ||
if (doc.activeElement !== this && doc.activeElement !== doc.body) { | ||
doc.activeElement.blur(this); | ||
} | ||
doc._setActiveElement(this); | ||
const focusEvent = new FocusEvent("focus", { bubbles: false }); | ||
this.dispatchEvent(focusEvent); | ||
} | ||
blur() { | ||
const focusEvent = new Event("blur", { bubbles: true }); | ||
blur(relatedTarget = null) { | ||
this[documentSymbol]._setActiveElement(null); | ||
const focusEvent = new FocusEvent("blur", { bubbles: false, relatedTarget }); | ||
this.dispatchEvent(focusEvent); | ||
} | ||
click() { | ||
if (this.disabled) return; | ||
if (this.nodeName === "SUMMARY") { | ||
this.closest("details").open = !this.closest("details").open; | ||
} | ||
const doc = this[documentSymbol]; | ||
if (doc.activeElement !== this && doc.activeElement !== doc.body) { | ||
doc.activeElement.blur(this); | ||
} | ||
this.dispatchEvent(new PointerEvent("click", { bubbles: true })); | ||
} | ||
get dataset() { | ||
@@ -31,0 +51,0 @@ return this[datasetSymbol]; |
@@ -9,2 +9,9 @@ "use strict"; | ||
} | ||
get disabled() { | ||
return this.$elm.prop("disabled"); | ||
} | ||
set disabled(value) { | ||
if (value === true) return this.setAttribute("disabled", "disabled"); | ||
this.removeAttribute("disabled"); | ||
} | ||
}; |
{ | ||
"name": "@expressen/tallahassee", | ||
"version": "14.10.3", | ||
"version": "14.11.0", | ||
"description": "Lightweight client testing framework", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
126411
3865
428