-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
152 additions
and
109 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
module.exports = require('./lib/xmlhttprequest'); | ||
module.exports = require('./lib'); | ||
})(); |
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 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
var XMLHttpRequest = require('./xmlhttprequest'); | ||
|
||
function AnonXMLHttpRequest() { | ||
if (!(this instanceof AnonXMLHttpRequest)) { | ||
throw new TypeError('DOM object constructor cannot be called as a function'); | ||
} | ||
XMLHttpRequest.call(this); | ||
} | ||
AnonXMLHttpRequest.prototype = Object.create(XMLHttpRequest.prototype); | ||
module.exports = AnonXMLHttpRequest; | ||
})(); |
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,30 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
function EventTarget() { | ||
Object.defineProperty(this, '_eventListeners', { | ||
value: {}, | ||
writable: true, | ||
enumerable: false, | ||
configurable: false | ||
}); | ||
} | ||
module.exports = EventTarget; | ||
|
||
(function(proto) { | ||
proto.addEventListener = function addEventListener(type, listener, useCapture) { | ||
this['on' + type] = listener; | ||
}; | ||
|
||
proto.dispatchEvent = function dispatchEvent(event) { | ||
var _listener = this['on' + event.type]; | ||
if (typeof(_listener) === 'function') { | ||
_listener.call(this, event); | ||
} | ||
}; | ||
|
||
proto.removeEventListener = function removeEventListener(type, listener, useCapture) { | ||
// todo | ||
}; | ||
})(EventTarget.prototype); | ||
})(); |
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,16 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
function FormData() { | ||
if (!(this instanceof FormData)) { | ||
throw new TypeError('DOM object constructor cannot be called as a function.'); | ||
} | ||
} | ||
module.exports = FormData; | ||
|
||
(function(proto) { | ||
proto.append = function append(name, value, filename) { | ||
// todo | ||
}; | ||
})(FormData.prototype); | ||
})(); |
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 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
var XMLHttpRequestUpload = require('./xmlhttprequestupload'); | ||
var XMLHttpRequest = require('./xmlhttprequest'); | ||
var AnonXMLHttpRequest = require('./anonxmlhttprequest'); | ||
var FormData = require('./formdata'); | ||
|
||
module.exports = { | ||
XMLHttpRequestUpload: XMLHttpRequestUpload, | ||
XMLHttpRequest: XMLHttpRequest, | ||
AnonXMLHttpRequest: AnonXMLHttpRequest, | ||
FormData: FormData | ||
}; | ||
})(); |
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,45 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
var EventTarget = require('./eventtarget'); | ||
|
||
function XMLHttpRequestEventTarget() { | ||
EventTarget.call(this); | ||
} | ||
XMLHttpRequestEventTarget.prototype = Object.create(EventTarget.prototype); | ||
module.exports = XMLHttpRequestEventTarget; | ||
|
||
(function(proto) { | ||
// Event handler | ||
(function(types) { | ||
types.forEach(function(type) { | ||
Object.defineProperty(proto, 'on' + type, { | ||
get: function() { | ||
var _listener = this._eventListeners[type]; | ||
if (typeof(_listener) !== 'function') { | ||
return null; | ||
} | ||
return _listener; | ||
}, | ||
set: function(listener) { | ||
if (typeof(listener) !== 'function') { | ||
delete this._eventListeners[type]; | ||
return listener; | ||
} | ||
return this._eventListeners[type] = listener; | ||
}, | ||
enumerable: true, | ||
configurable: false | ||
}); | ||
}); | ||
})([ | ||
'loadstart', | ||
'progress', | ||
'abort', | ||
'error', // todo | ||
'load', | ||
'timeout', // todo | ||
'loadend' | ||
]); | ||
})(XMLHttpRequestEventTarget.prototype); | ||
})(); |
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,13 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
var XMLHttpRequestResponseType = [ | ||
'', | ||
'arraybuffer', | ||
'blob', | ||
'document', | ||
'json', | ||
'text' | ||
]; | ||
module.exports = XMLHttpRequestResponseType; | ||
})(); |
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 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
var XMLHttpRequestEventTarget = require('./xmlhttprequesteventtarget'); | ||
|
||
function XMLHttpRequestUpload() { | ||
if (!(this instanceof XMLHttpRequestUpload)) { | ||
throw new TypeError('DOM object constructor cannot be called as a function.'); | ||
} | ||
XMLHttpRequestEventTarget.call(this); | ||
} | ||
XMLHttpRequestUpload.prototype = Object.create(XMLHttpRequestEventTarget.prototype); | ||
module.exports = XMLHttpRequestUpload; | ||
})(); |