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

Commit a5cec66

Browse files
committed
v0.3.5
1 parent 75a7eec commit a5cec66

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

dist/hint.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ var AVAILABLE_MODULES = [
2626
];
2727

2828
var SEVERITY_WARNING = 2;
29+
var DEFER_LABEL = 'NG_DEFER_BOOTSTRAP!';
2930

31+
var deferRegex = new RegExp('^' + DEFER_LABEL + '.*');
3032
// Determine whether this run is by protractor.
3133
// If protractor is running, the bootstrap will already be deferred.
3234
// In this case `resumeBootstrap` should be patched to load the hint modules.
33-
if (window.name === 'NG_DEFER_BOOTSTRAP!') {
35+
if (deferRegex.test(window.name)) {
3436
var originalResumeBootstrap;
3537
Object.defineProperty(angular, 'resumeBootstrap', {
3638
get: function() {
@@ -45,10 +47,19 @@ if (window.name === 'NG_DEFER_BOOTSTRAP!') {
4547
}
4648
//If this is not a test, defer bootstrapping
4749
else {
48-
window.name = 'NG_DEFER_BOOTSTRAP!';
50+
window.name = DEFER_LABEL + window.name;
4951

5052
// determine which modules to load and resume bootstrap
5153
document.addEventListener('DOMContentLoaded', maybeBootstrap);
54+
55+
/* angular should remove DEFER_LABEL from window.name, but if angular is never loaded, we want
56+
to remove it ourselves, otherwise hint will incorrectly detect protractor as being present on
57+
the next page load */
58+
window.addEventListener('beforeunload', function() {
59+
if (deferRegex.test(window.name)) {
60+
window.name = window.name.substring(DEFER_LABEL.length);
61+
}
62+
});
5263
}
5364

5465
function maybeBootstrap() {
@@ -1382,7 +1393,7 @@ function decorateRootScope($delegate, $parse) {
13821393
value: value
13831394
};
13841395
hint.emit('model:change', {
1385-
id: scopeId,
1396+
id: convertIdToOriginalType(scopeId),
13861397
path: partialPath,
13871398
value: value
13881399
});
@@ -1589,7 +1600,7 @@ function decorateRootScope($delegate, $parse) {
15891600
var value = summarize(model.get());
15901601
if (value !== model.value) {
15911602
hint.emit('model:change', {
1592-
id: (angular.version.minor < 3) ? scopeId : parseInt(scopeId),
1603+
id: convertIdToOriginalType(scopeId),
15931604
path: path,
15941605
oldValue: model.value,
15951606
value: value
@@ -1680,4 +1691,8 @@ function isOneTimeBindExp(exp) {
16801691
return exp.charAt(0) === ':' && exp.charAt(1) === ':';
16811692
}
16821693

1694+
function convertIdToOriginalType(scopeId) {
1695+
return (angular.version.minor < 3) ? scopeId : parseInt(scopeId, 10);
1696+
}
1697+
16831698
},{"../lib/summarize-model":7,"debounce-on":2}]},{},[1]);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-hint",
3-
"version": "0.3.4",
3+
"version": "0.3.5",
44
"description": "run-time hinting for AngularJS applications",
55
"main": "hint.js",
66
"scripts": {

0 commit comments

Comments
 (0)