Skip to content

Commit 1849eae

Browse files
author
William Troup
authored
Merge pull request #10 from williamtroup/0.8.0
0.8.0
2 parents 53eb28e + ee998de commit 1849eae

File tree

12 files changed

+151
-87
lines changed

12 files changed

+151
-87
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
Observe.js
33

44
[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Observe.js%2C%20a%20free%20JavaScript%observe%builder&url=https://github.com/williamtroup/Observe.js&hashtags=javascript,html,observe)
5-
[![npm](https://img.shields.io/badge/npmjs-v0.7.1-blue)](https://www.npmjs.com/package/jobserve.js)
6-
[![nuget](https://img.shields.io/badge/nuget-v0.7.1-purple)](https://www.nuget.org/packages/jObserve.js/)
5+
[![npm](https://img.shields.io/badge/npmjs-v0.8.0-blue)](https://www.npmjs.com/package/jobserve.js)
6+
[![nuget](https://img.shields.io/badge/nuget-v0.8.0-purple)](https://www.nuget.org/packages/jObserve.js/)
77
[![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/williamtroup/Observe.js/blob/main/LICENSE.txt)
88
[![discussions Welcome](https://img.shields.io/badge/discussions-Welcome-red)](https://github.com/williamtroup/Observe.js/discussions)
99
[![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://www.william-troup.com/)
1010
</h1>
1111

1212
> <p align="center">A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.</p>
13-
> <p align="center">v0.7.1</p>
13+
> <p align="center">v0.8.0</p>
1414
<br />
1515
<br>
1616

README_NUGET.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Observe.js v0.7.1
1+
# Observe.js v0.8.0
22

33
[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Observe.js%2C%20a%20free%20JavaScript%observe%builder&url=https://github.com/williamtroup/Observe.js&hashtags=javascript,html,observe)
4-
[![npm](https://img.shields.io/badge/npmjs-v0.7.1-blue)](https://www.npmjs.com/package/jobserve.js)
5-
[![nuget](https://img.shields.io/badge/nuget-v0.7.1-purple)](https://www.nuget.org/packages/jObserve.js/)
4+
[![npm](https://img.shields.io/badge/npmjs-v0.8.0-blue)](https://www.npmjs.com/package/jobserve.js)
5+
[![nuget](https://img.shields.io/badge/nuget-v0.8.0-purple)](https://www.nuget.org/packages/jObserve.js/)
66
[![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/williamtroup/Observe.js/blob/main/LICENSE.txt)
77
[![discussions Welcome](https://img.shields.io/badge/discussions-Welcome-red)](https://github.com/williamtroup/Observe.js/discussions)
88
[![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://www.william-troup.com/)

dist/observe.js

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Observe.js v0.7.1 | (c) Bunoon 2024 | MIT License */
1+
/*! Observe.js v0.8.0 | (c) Bunoon 2024 | MIT License */
22
(function() {
33
function collectDOMObjects() {
44
var tagTypes = _configuration.domElementTypes;
@@ -27,19 +27,17 @@
2727
if (!isDefinedString(element.id)) {
2828
element.id = newGuid();
2929
}
30-
element.removeAttribute(_attribute_Name_Watch_Options);
30+
if (bindingOptions.removeAttribute) {
31+
element.removeAttribute(_attribute_Name_Watch_Options);
32+
}
3133
createWatch(element, bindingOptions, element.id);
3234
} else {
33-
if (!_configuration.safeMode) {
34-
console.error("The attribute '" + _attribute_Name_Watch_Options + "' is not a valid object.");
35-
result = false;
36-
}
37-
}
38-
} else {
39-
if (!_configuration.safeMode) {
40-
console.error("The attribute '" + _attribute_Name_Watch_Options + "' has not been set correctly.");
35+
logError(_configuration.attributeNotValidErrorText.replace("{{attribute_name}}", _attribute_Name_Watch_Options));
4136
result = false;
4237
}
38+
} else {
39+
logError(_configuration.attributeNotSetErrorText.replace("{{attribute_name}}", _attribute_Name_Watch_Options));
40+
result = false;
4341
}
4442
}
4543
return result;
@@ -206,7 +204,7 @@
206204
return result;
207205
}
208206
function getWatchOptions(newOptions) {
209-
var options = !isDefinedObject(newOptions) ? {} : newOptions;
207+
var options = getDefaultObject(newOptions, {});
210208
options.timeout = getDefaultNumber(options.timeout, 250);
211209
options.starts = getDefaultDate(options.starts, null);
212210
options.expires = getDefaultDate(options.expires, null);
@@ -217,6 +215,7 @@
217215
options.propertyNames = getDefaultArray(options.propertyNames, null);
218216
options.allowCanceling = getDefaultBoolean(options.allowCanceling, true);
219217
options.allowPausing = getDefaultBoolean(options.allowPausing, true);
218+
options.removeAttribute = getDefaultBoolean(options.removeAttribute, true);
220219
options = getWatchOptionsCustomTriggers(options);
221220
return options;
222221
}
@@ -278,12 +277,18 @@
278277
function getDefaultNumber(value, defaultValue) {
279278
return isDefinedNumber(value) ? value : defaultValue;
280279
}
280+
function getDefaultString(value, defaultValue) {
281+
return isDefinedString(value) ? value : defaultValue;
282+
}
281283
function getDefaultDate(value, defaultValue) {
282284
return isDefinedDate(value) ? value : defaultValue;
283285
}
284286
function getDefaultArray(value, defaultValue) {
285287
return isDefinedArray(value) ? value : defaultValue;
286288
}
289+
function getDefaultObject(value, defaultValue) {
290+
return isDefinedObject(value) ? value : defaultValue;
291+
}
287292
function getDefaultStringOrArray(value, defaultValue) {
288293
if (isDefinedString(value)) {
289294
value = value.split(_string.space);
@@ -309,7 +314,7 @@
309314
result = result();
310315
}
311316
} catch (e2) {
312-
parsed = logError("Errors in object: " + e1.message + ", " + e2.message);
317+
parsed = logError(_configuration.objectErrorText.replace("{{error_1}}", e1.message).replace("{{error_2}}", e2.message));
313318
result = null;
314319
}
315320
}
@@ -326,6 +331,12 @@
326331
function buildDefaultConfiguration() {
327332
_configuration.safeMode = getDefaultBoolean(_configuration.safeMode, true);
328333
_configuration.domElementTypes = getDefaultStringOrArray(_configuration.domElementTypes, ["*"]);
334+
buildDefaultConfigurationStrings();
335+
}
336+
function buildDefaultConfigurationStrings() {
337+
_configuration.objectErrorText = getDefaultString(_configuration.objectErrorText, "Errors in object: {{error_1}}, {{error_2}}");
338+
_configuration.attributeNotValidErrorText = getDefaultString(_configuration.attributeNotValidErrorText, "The attribute '{{attribute_name}}' is not a valid object.");
339+
_configuration.attributeNotSetErrorText = getDefaultString(_configuration.attributeNotSetErrorText, "The attribute '{{attribute_name}}' has not been set correctly.");
329340
}
330341
var _parameter_Document = null;
331342
var _parameter_Window = null;
@@ -432,13 +443,13 @@
432443
collectDOMObjects();
433444
return this;
434445
};
435-
this.setConfiguration = function(newOptions) {
436-
_configuration = !isDefinedObject(newOptions) ? {} : newOptions;
446+
this.setConfiguration = function(newConfiguration) {
447+
_configuration = getDefaultObject(newConfiguration, {});
437448
buildDefaultConfiguration();
438449
return this;
439450
};
440451
this.getVersion = function() {
441-
return "0.7.1";
452+
return "0.8.0";
442453
};
443454
(function(documentObject, windowObject, mathObject, jsonObject) {
444455
_parameter_Document = documentObject;

dist/observe.min.js

Lines changed: 14 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)