Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio-main
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Hardik Juneja
jio-main
Commits
0d528f2a
Commit
0d528f2a
authored
Jun 03, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
newClass function now secures static methods
parent
9287baec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
3 deletions
+28
-3
src/queries/tool.js
src/queries/tool.js
+28
-3
No files found.
src/queries/tool.js
View file @
0d528f2a
...
...
@@ -12,6 +12,11 @@
* @param {Boolean} [option.secure_methods=false] Make methods not configurable
* and not writable
* @param {Boolean} [option.hide_methods=false] Make methods not enumerable
* @param {Boolean} [option.secure_static_methods=true] Make static methods not
* configurable and not
* writable
* @param {Boolean} [option.hide_static_methods=false] Make static methods not
* enumerable
* @param {Object} [option.static_methods={}] Object of static methods
* @param {Function} constructor The new class constructor
* @return {Class} The new class
...
...
@@ -32,7 +37,7 @@ function newClass() {
}
}
function
post
Create
(
that
)
{
function
post
ObjectCreation
(
that
)
{
// modify the object according to 'option'
var
key
;
if
(
option
)
{
...
...
@@ -51,6 +56,26 @@ function newClass() {
}
}
function
postClassCreation
(
that
)
{
// modify the object according to 'option'
var
key
;
if
(
option
)
{
for
(
key
in
that
)
{
if
(
that
.
hasOwnProperty
(
key
))
{
if
(
typeof
that
[
key
]
===
"
function
"
)
{
Object
.
defineProperty
(
that
,
key
,
{
configurable
:
option
.
secure_static_methods
===
false
?
true
:
false
,
enumerable
:
option
.
hide_static_methods
?
false
:
true
,
writable
:
option
.
secure_static_methods
===
false
?
true
:
false
,
value
:
that
[
key
]
});
}
}
}
}
}
new_class
=
function
(
spec
,
my
)
{
var
i
;
spec
=
spec
||
{};
...
...
@@ -59,7 +84,7 @@ function newClass() {
for
(
i
=
0
;
i
<
constructors
.
length
;
i
+=
1
)
{
constructors
[
i
].
apply
(
this
,
[
spec
,
my
]);
}
post
Create
(
this
);
post
ObjectCreation
(
this
);
return
this
;
};
option
=
option
||
{};
...
...
@@ -69,7 +94,7 @@ function newClass() {
new_class
[
j
]
=
option
.
static_methods
[
j
];
}
}
postC
reate
(
new_class
);
postC
lassCreation
(
new_class
);
return
new_class
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment