Skip to content

Commit

Permalink
Added a special check to the processObject method to make sure it doe…
Browse files Browse the repository at this point in the history
…s not process constructor methods which is an issue
  • Loading branch information
alex-solvexia committed Jul 30, 2019
1 parent 1bd67ca commit f97486c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
.DS_Store
.package.json.swp
.package.json.swp
*.iml
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### Core 0.1.9

- Added a special check to the processObject method to make sure it does not process constructor methods which is an issue
for some cases when Javascript precompilers which add constructor as a enumerable property to classes.

- Added a licence file (MIT)

### Core 0.1.8

- Added support for @types for Typescript.
3 changes: 2 additions & 1 deletion Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,10 @@ Core = {
}
for( var method in _class ) {
var events;
var isConstructor = method === 'constructor'; // some precompilers add constructor as a enumerable property which causes side-effects in Core
var isGetter = _class instanceof Object && Object.getOwnPropertyDescriptor(_class, method) && Object.getOwnPropertyDescriptor(_class, method).get;
// check if property is actually getter to prevent getters from calling (it can be js errors because of calling)
if (!isGetter && _class[method] instanceof Function ) {
if (!isGetter && _class[method] instanceof Function && !isConstructor ) {
if( events = _class[method].toString().replace(/\n/g,"").match(/(Core\.)?(CatchEvent|CatchRequest)\(([^\)]+)\)/m) ) {
events = events[3].replace(/^[ \t\n\r]*|[ \t\n\r]*$/mg,"").split(/[ \t\n\r]*,[ \t\n\r]*/);
for( var i = 0; i < events.length; i++ ) {
Expand Down
23 changes: 23 additions & 0 deletions LICENCE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
MIT License (MIT)

Copyright (c) 2016 extremeprog-com

All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 3 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ interface Core {
FireEvent (Request: CoreRequest, success?: Function, fail?: Function) :void;
FireRequest(Event : CoreEvent) :void;

CatchEvent(...args: any) : CoreRequest;
CatchEvent (...args: any): CoreEvent;
CatchRequest(...args: any): CoreRequest;

detachObject (Object: Object): Object;
processObject(Object: Object): Object;
}

declare type CoreRequest = { _request: string } & {[key: string]: any};
declare type CoreEvent = { _event : string } & {[key: string]: any};
declare interface CoreRequest { _request: string, [key: string]: any}
declare interface CoreEvent { _event : string, [key: string]: any}

0 comments on commit f97486c

Please sign in to comment.