Skip to content

Commit

Permalink
Bugfixes, new package structure
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxArt2501 committed Jan 28, 2015
1 parent dc2c6f9 commit 80393ed
Show file tree
Hide file tree
Showing 13 changed files with 409 additions and 177 deletions.
49 changes: 49 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.gitignore
.gitattributes
dist/object-observe.min.js
dist/object-observe-lite.min.js
bower.json

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

# =========================
# Operating System Files
# =========================

# OSX
# =========================

.DS_Store
.AppleDouble
.LSOverride

# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
26 changes: 26 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "object.observe",
"version": "0.2.1",
"homepage": "https://github.com/MaxArt2501/object-observe",
"authors": [
"Massimo Artizzu <maxart.x@gmail.com>"
],
"description": "Object.observe polyfill based on ES7 spec",
"main": "dist/object-observe.min.js",
"moduleType": [
"globals"
],
"keywords": [
"observe",
"data-binding",
"Object.observe"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}
9 changes: 9 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## v0.2.1

2015-01-28

* Desynch event delivering on `Object.unobserve`
* Package restructuring, splitted documentation
* `npm` module (`object.observe`)
* `bower` module (`object.observe`)

## v0.2.0

2015-01-26
Expand Down
6 changes: 4 additions & 2 deletions object-observe-lite.js → dist/object-observe-lite.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Object.observe "lite" polyfill - v0.2.0
* Object.observe "lite" polyfill - v0.2.1
* by Massimo Artizzu (MaxArt2501)
*
* https://github.com/MaxArt2501/object-observe
Expand Down Expand Up @@ -498,7 +498,9 @@ Object.observe || (function(O, A, root) {
hdata.observed.forEach(function(odata, object) {
performPropertyChecks(odata.data, object);
});
deliverHandlerRecords(hdata, handler);
nextFrame(function() {
deliverHandlerRecords(hdata, handler);
});

// In Firefox 13-18, size is a function, but createMap should fall
// back to the shim for those versions
Expand Down
14 changes: 7 additions & 7 deletions object-observe-lite.min.js → dist/object-observe-lite.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 33 additions & 31 deletions object-observe.js → dist/object-observe.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Object.observe polyfill - v0.2.0
* Object.observe polyfill - v0.2.1
* by Massimo Artizzu (MaxArt2501)
*
* https://github.com/MaxArt2501/object-observe
Expand Down Expand Up @@ -76,8 +76,7 @@ Object.observe || (function(O, A, root) {
*/
handlers,

defaultObjectAccepts = [ "add", "update", "delete", "reconfigure", "setPrototype", "preventExtensions" ],
defaultArrayAccepts = [ "add", "update", "delete", "splice" ];
defaultAcceptList = [ "add", "update", "delete", "reconfigure", "setPrototype", "preventExtensions" ];

// Functions for internal usage

Expand Down Expand Up @@ -243,32 +242,6 @@ Object.observe || (function(O, A, root) {
}
},

/**
* Sets up the main loop for object observation and change notification
* It stops if no object is observed.
* @function runGlobalLoop
*/
runGlobalLoop = function() {
if (observed.size) {
observed.forEach(performPropertyChecks);
handlers.forEach(deliverHandlerRecords);
nextFrame(runGlobalLoop);
}
},

/**
* Deliver the change records relative to a certain handler, and resets
* the record list.
* @param {HandlerData} hdata
* @param {Handler} handler
*/
deliverHandlerRecords = function(hdata, handler) {
if (hdata.changeRecords.length) {
handler(hdata.changeRecords);
hdata.changeRecords = [];
}
},

/**
* Creates the initial data for an observed object
* @function createObjectData
Expand Down Expand Up @@ -499,6 +472,33 @@ Object.observe || (function(O, A, root) {
};
})(),

/**
* Sets up the main loop for object observation and change notification
* It stops if no object is observed.
* @function runGlobalLoop
*/
runGlobalLoop = function() {
if (observed.size) {
observed.forEach(performPropertyChecks);
handlers.forEach(deliverHandlerRecords);
nextFrame(runGlobalLoop);
}
},

/**
* Deliver the change records relative to a certain handler, and resets
* the record list.
* @param {HandlerData} hdata
* @param {Handler} handler
*/
deliverHandlerRecords = function(hdata, handler) {
if (hdata.changeRecords.length) {
handler(hdata.changeRecords);
hdata.changeRecords = [];
}
},


/**
* Returns the notifier for an object - whether it's observed or not
* @function retrieveNotifier
Expand Down Expand Up @@ -633,7 +633,7 @@ Object.observe || (function(O, A, root) {
throw new TypeError("Object.observe cannot deliver to a frozen function object");

if (!isArray(acceptList))
acceptList = defaultObjectAccepts;
acceptList = defaultAcceptList;

doObserve(object, handler, acceptList);

Expand Down Expand Up @@ -661,7 +661,9 @@ Object.observe || (function(O, A, root) {
hdata.observed.forEach(function(odata, object) {
performPropertyChecks(odata.data, object);
});
deliverHandlerRecords(hdata, handler);
nextFrame(function() {
deliverHandlerRecords(hdata, handler);
});

// In Firefox 13-18, size is a function, but createMap should fall
// back to the shim for those versions
Expand Down
12 changes: 12 additions & 0 deletions dist/object-observe.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 80393ed

Please sign in to comment.