forked from seajs/seajs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Module._getCompilingModule method. close seajs#223
- Loading branch information
1 parent
2288ba3
commit f11c90a
Showing
10 changed files
with
136 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
define(function(require) { | ||
|
||
var oo = require('./oo') | ||
|
||
|
||
function Animal() { | ||
} | ||
|
||
oo.inherits(Animal, Object) | ||
|
||
Animal.prototype.isAnimal = true | ||
return Animal | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
define(function(require) { | ||
|
||
var oo = require('./oo') | ||
var Animal = require('./animal') | ||
|
||
|
||
function Dog() { | ||
} | ||
|
||
oo.inherits(Dog, Animal) | ||
|
||
Dog.prototype.isDog = true | ||
return Dog | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
define(function(require) { | ||
|
||
var test = require('../../test') | ||
|
||
var Dog = require('./dog') | ||
var dog = new Dog() | ||
|
||
seajs.log(dog, 'dir') | ||
|
||
test.assert(dog.isAnimal === true, dog.isAnimal) | ||
test.assert(dog.isDog === true, dog.isDog) | ||
test.assert(dog.__filename === 'dog.js', dog.__filename) | ||
test.assert(dog.__module.dependencies.length === 2, dog.__module.dependencies) | ||
|
||
test.done() | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
define(function(require, exports) { | ||
|
||
|
||
exports.inherits = function(ctor, superCtor) { | ||
|
||
ctor.prototype = createProto(superCtor.prototype) | ||
|
||
// Adds meta info | ||
var compilingModule = seajs.pluginSDK.Module._getCompilingModule() | ||
var filename = compilingModule.uri.split(/[\/\\]/).pop() | ||
|
||
if (Object.defineProperties) { | ||
Object.defineProperties(ctor.prototype, { | ||
__module: { value: compilingModule }, | ||
__filename: { value: filename } | ||
}) | ||
} | ||
else { | ||
ctor.prototype.__module = compilingModule | ||
ctor.prototype.__filename = filename | ||
} | ||
} | ||
|
||
|
||
// Shared empty constructor function to aid in prototype-chain creation. | ||
function Ctor() { | ||
} | ||
|
||
// See: http://jsperf.com/object-create-vs-new-ctor | ||
var createProto = Object.__proto__ ? | ||
function(proto) { | ||
return { __proto__: proto } | ||
} : | ||
function(proto) { | ||
Ctor.prototype = proto | ||
return new Ctor() | ||
} | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Issue Test</title> | ||
<script> | ||
function printResults(txt, style) { | ||
var d = document.createElement('div'); | ||
d.innerHTML = txt; | ||
d.className = style; | ||
document.getElementById('out').appendChild(d); | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
|
||
<p><a href="https://github.com/seajs/seajs/issues/223">#223</a></p> | ||
<div id="out"></div> | ||
|
||
<script src="../../../dist/sea-debug.js"></script> | ||
<script> | ||
seajs.use('./main') | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters