@ribajs/core
Advanced tools
Comparing version 1.9.0-beta.0 to 1.9.0-beta.1
{ | ||
"name": "@ribajs/core", | ||
"description": "Core module of Riba.js", | ||
"version": "1.9.0-beta.0", | ||
"version": "1.9.0-beta.1", | ||
"author": "Pascal Garber <pascal@artandcode.studio>", | ||
@@ -52,5 +52,5 @@ "contributors": [ | ||
"@babel/runtime-corejs3": "^7.11.2", | ||
"@ribajs/eslint-config": "1.9.0-beta.0", | ||
"@ribajs/tsconfig": "1.9.0-beta.0", | ||
"@ribajs/types": "1.9.0-beta.0", | ||
"@ribajs/eslint-config": "1.9.0-beta.1", | ||
"@ribajs/tsconfig": "1.9.0-beta.1", | ||
"@ribajs/types": "1.9.0-beta.1", | ||
"@types/core-js": "^2.5.3", | ||
@@ -86,4 +86,4 @@ "@types/jest": "^26.0.13", | ||
"dependencies": { | ||
"@ribajs/utils": "1.9.0-beta.0" | ||
"@ribajs/utils": "1.9.0-beta.1" | ||
} | ||
} |
@@ -0,2 +1,4 @@ | ||
/* eslint-disable @typescript-eslint/no-this-alias */ | ||
import { Binder } from "../interfaces"; | ||
import { getInputValue } from "@ribajs/utils/src/dom"; | ||
import { getString } from "@ribajs/utils/src/type"; | ||
@@ -14,4 +16,22 @@ | ||
onChange() { | ||
this.publish(); | ||
}, | ||
bind(el) { | ||
el.addEventListener("change", this.publish); | ||
const self = this; | ||
this.customData = this.customData || {}; | ||
if (!this.customData.onChange) { | ||
this.customData.onChange = () => { | ||
self.publish(); | ||
}; | ||
} | ||
el.addEventListener("change", this.customData.onChange, false); | ||
// el.addEventListener("click", this.customData.onChange, false); | ||
// el.addEventListener("input", this.customData.onChange, false); | ||
// el.addEventListener("focus", this.customData.onChange, false); | ||
// el.addEventListener("blur", this.customData.onChange, false); | ||
(el as HTMLInputElement).checked = !!(el as HTMLInputElement).checked; | ||
@@ -21,17 +41,22 @@ }, | ||
unbind(el) { | ||
el.removeEventListener("change", this.publish); | ||
el.removeEventListener(this.customData.event, this.customData.onChange); | ||
// el.addEventListener("click", this.customData.onChange); | ||
// el.addEventListener("input", this.customData.onChange); | ||
// el.addEventListener("focus", this.customData.onChange); | ||
// el.addEventListener("blur", this.customData.onChange); | ||
}, | ||
routine(el: HTMLElement, value) { | ||
routine(el: HTMLElement, newValue) { | ||
const oldValue = this.getValue(el); | ||
if ((el as HTMLInputElement).type === "radio") { | ||
(el as HTMLInputElement).checked = | ||
getString((el as HTMLInputElement).value) === getString(value); | ||
getString(oldValue) === getString(newValue); | ||
} else { | ||
(el as HTMLInputElement).checked = !!value; | ||
if (oldValue !== newValue) { | ||
(el as HTMLInputElement).checked = !!newValue; | ||
} | ||
} | ||
}, | ||
getValue(el) { | ||
return !!(el as HTMLInputElement).checked; | ||
}, | ||
getValue: getInputValue, | ||
}; |
@@ -18,5 +18,5 @@ import { Binder } from "../interfaces"; | ||
} else { | ||
(el.style as any)[propertyName] = value; | ||
(el.style as any).setProperty(propertyName, value); | ||
} | ||
}, | ||
}; |
@@ -46,7 +46,8 @@ import { Binder } from "../interfaces"; | ||
if (!this.customData.event) { | ||
this.customData.event = "change input keyup paste blur focus"; | ||
} | ||
el.addEventListener(this.customData.event, this.customData.onChange); | ||
el.addEventListener("change", this.customData.onChange, false); | ||
el.addEventListener("input", this.customData.onChange, false); | ||
el.addEventListener("keyup", this.customData.onChange, false); | ||
el.addEventListener("paste", this.customData.onChange, false); | ||
el.addEventListener("blur", this.customData.onChange, false); | ||
el.addEventListener("focus", this.customData.onChange, false); | ||
} | ||
@@ -56,3 +57,8 @@ }, | ||
unbind(el: HTMLUnknownElement) { | ||
el.removeEventListener(this.customData.event, this.customData.onChange); | ||
el.removeEventListener("change", this.customData.onChange); | ||
el.removeEventListener("input", this.customData.onChange); | ||
el.removeEventListener("keyup", this.customData.onChange); | ||
el.removeEventListener("paste", this.customData.onChange); | ||
el.removeEventListener("blur", this.customData.onChange); | ||
el.removeEventListener("focus", this.customData.onChange); | ||
}, | ||
@@ -59,0 +65,0 @@ |
@@ -19,2 +19,1 @@ import { RibaModule } from "./interfaces"; | ||
export { coreModule }; | ||
export default coreModule; |
@@ -154,3 +154,4 @@ import { concat } from "@ribajs/utils/src/type"; | ||
try { | ||
resolve(JSON.parse(req.responseText)); | ||
const responseText = JSON.parse(req.responseText); | ||
resolve(responseText); | ||
} catch (error) { | ||
@@ -157,0 +158,0 @@ // If json can't be parsed |
@@ -164,3 +164,3 @@ import { Riba } from "./riba"; | ||
this.bindings.forEach((binding) => { | ||
if (binding.binder && binding.publish && binding.binder.publishes) { | ||
if (binding.binder && binding.binder.publishes && binding.publish) { | ||
binding.publish(); | ||
@@ -167,0 +167,0 @@ } |
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
275540
8500
+ Added@ribajs/utils@1.9.0-beta.1(transitive)
- Removed@ribajs/utils@1.9.0-beta.0(transitive)
Updated@ribajs/utils@1.9.0-beta.1