Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

WIP STAGING for #8300 [[no-merge]] #8067

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,11 @@ module.exports = function(grunt) {
},
"promises-aplus-adapter": {
dest:'tmp/promises-aplus-adapter++.js',
src:['src/ng/q.js','lib/promises-aplus/promises-aplus-test-adapter.js']
src: [
'lib/promises-aplus/promises-aplus-test-adapter-prefix.js',
'src/ng/q.js',
'lib/promises-aplus/promises-aplus-test-adapter.js'
]
}
},

Expand Down
35 changes: 35 additions & 0 deletions lib/promises-aplus/promises-aplus-test-adapter-prefix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"use strict";
var INVISIBLE = 1;
var CONFIGURABLE = 2;
var WRITABLE = 4;

var defineProperty = function(target, propertyName, flags, value) {
if (typeof target === 'object' || typeof target === 'function') {
var desc = {
/*jshint bitwise: false */
enumerable: !(flags & INVISIBLE),
configurable: !!(flags & CONFIGURABLE),
writable: !!(flags & WRITABLE)
};
if (arguments.length > 3) {
desc.value = value;
}
Object.defineProperty(target, propertyName, desc);
}
};

var defineProperties = function(target, flags, properties) {
for (var key in properties) {
if (properties.hasOwnProperty(key)) {
defineProperty(target, key, flags, properties[key]);
}
}
};

var createObject = Object.create;

function bind1(self, fn) {
return function(value) {
return fn.call(self, value);
};
}
7 changes: 7 additions & 0 deletions src/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"concat": false,
"sliceArgs": false,
"bind": false,
"bind1": false,
"toJsonReplacer": false,
"toJson": false,
"fromJson": false,
Expand All @@ -87,6 +88,12 @@
"getter": false,
"getBlockElements": false,
"VALIDITY_STATE_PROPERTY": false,
"INVISIBLE": true,
"CONFIGURABLE": true,
"WRITABLE": true,
"defineProperty": false,
"defineProperties": false,
"createObject": false,

/* filters.js */
"getFirstThursdayOfYear": false,
Expand Down
49 changes: 49 additions & 0 deletions src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
concat: true,
sliceArgs: true,
bind: true,
bind1: true,
toJsonReplacer: true,
toJson: true,
fromJson: true,
Expand Down Expand Up @@ -998,6 +999,18 @@ function bind(self, fn) {
}


function bind1(self, fn) {
// For performance reasons, no sanity-checks are performed here. This method is not publicly
// exposed, and so failures here should cause test failures in core if issues are present.
//
// Due to not currying arguments, and not testing for error conditions, this should perform
// somewhat better than angular.bind() for the cases where it is needed.
return function(value) {
return fn.call(self, value);
};
}


function toJsonReplacer(key, value) {
var val = value;

Expand Down Expand Up @@ -1572,3 +1585,39 @@ function getBlockElements(nodes) {

return jqLite(elements);
}

var INVISIBLE = 1;
var CONFIGURABLE = 2;
var WRITABLE = 4;

function defineProperty(target, propertyName, flags, value) {
if (isObject(target) || isFunction(target)) {
if (Object.defineProperty) {
var desc = {
/*jshint bitwise: false */
enumerable: !(flags & INVISIBLE),
configurable: !!(flags & CONFIGURABLE),
writable: !!(flags & WRITABLE)
};
if (arguments.length > 3) {
desc.value = value;
}
Object.defineProperty(target, propertyName, desc);
} else {
target[propertyName] = value;
}
}
}

function defineProperties(target, flags, propertyNameAndValues) {
forEach(propertyNameAndValues, function(value, propertyName) {
defineProperty(target, propertyName, flags, value);
});
}

function createObject(prototype) {
if (Object.create) return Object.create(prototype);
function C() {}
C.prototype = prototype;
return new C();
}
2 changes: 1 addition & 1 deletion src/ng/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ function $HttpProvider() {
// normalize internal statuses to 0
status = Math.max(status, 0);

(isSuccess(status) ? deferred.resolve : deferred.reject)({
deferred[(isSuccess(status) ? 'resolve' : 'reject')]({
data: response,
status: status,
headers: headersGetter(headers),
Expand Down
Loading