Commit graph

66 commits

Author SHA1 Message Date
Codier
29f9e2665d fix(scope): $watch (and angular.equals) should support NaN values
- since NaN !== NaN in javascript digest can get into an infinite loop
  when model value is set to NaN
- angular.equals(NaN, NaN) should return true since that's what we
  expect when comparing primitives or objects containing NaN values

Previously NaN because of its special === properties was used as the
initial value for watches, but that results in issues when NaN is used
as model value.

In order to allow for model to be anything incuding undefined and NaN we
need to mark the initial value differently in a way that would avoid
these issues, allow us to run digest without major perf penalties and
allow for clients to determine if the listener is being called because
the watcher is being initialized or because the model changed. This
implementation covers all of these scenarios.

BREAKING CHANGE: previously to detect if the listener was called because
the watcher was being initialized, it was suggested that clients check
if old value is NaN. With this change, the check should be if the newVal
equals the oldVal.

Closes #657
2011-11-21 15:43:12 -08:00
Misko Hevery
e88dfb734a refactor(injector): $injector is no longer a function.
- $injector('abc') -> $injector.get('abc');
- $injector(fn) -> $injector.invoke(null, fn);
2011-11-14 20:31:19 -08:00
Misko Hevery
8d6dc0b9a7 del($eager): removed the support for $eager services 2011-11-14 20:31:19 -08:00
Misko Hevery
186a840cd3 feat(bootstrap): added angular.bootstrap method 2011-11-14 20:31:18 -08:00
Misko Hevery
bd04316a89 refactor(services): migrate angular.service -> module 2011-11-14 16:39:33 -08:00
Misko Hevery
ed36b9da3b refactor(injector): switch to injector 2.0 introduce modules 2011-11-14 16:39:32 -08:00
Misko Hevery
c925f8a657 new(injector): new injector v2.0
- not connected to keep the CL small
2011-11-14 16:39:32 -08:00
Misko Hevery
d12df0d360 refactor(compiler) turn compiler into a service
BREAK
- remove angular.compile() since the compile method is now a service and needs to be injected
2011-11-14 16:39:32 -08:00
Misko Hevery
48697a2b86 refactor(injector): turn scope into a service
- turn scope into a $rootScope service.
- injector is now a starting point for creating angular application.
- added inject() method which wraps jasmine its/beforeEach/afterEach,
  and which allows configuration and injection of services.
- refactor tests to use inject() where possible

BREAK:
- removed angular.scope() method
2011-11-14 16:39:31 -08:00
Igor Minar
1e00db8daa fix(directives): make directive names case-insensitive
+ tests
+ added docs for angular.directive
2011-11-08 21:44:46 -08:00
Igor Minar
d7ba5bc83b feat(bootstrap): drop angular.js file name restrictions for autobind
The last script element in the dom is always us if the script that
contains angular is loaded synchronously.

For async loading manual bootstrap needs to be performed.

Close #621
2011-10-26 12:57:15 -07:00
Misko Hevery
fd822bdaf9 chore(formating): clean code to be function() { 2011-10-11 11:01:46 -07:00
Misko Hevery
4f78fd692c feat(forms): new and improved forms 2011-10-11 11:01:45 -07:00
Misko Hevery
e134a8335f fix(filter): make json filter ignore private properties 2011-10-11 10:53:03 -07:00
Igor Minar
7ae536d053 fix(specs): various fixes to get IE8+jquery unit tests green 2011-09-16 02:44:33 +02:00
Misko Hevery
c9e7fb894b style(tests): correct indentation 2011-08-30 22:05:13 -07:00
Misko Hevery
42062dab34 refactor(scope): remove $flush/$observe ng:eval/ng:eval-order 2011-08-12 15:47:47 -07:00
Misko Hevery
8f0dcbab80 feat(scope): new and improved scope implementation
- Speed improvements (about 4x on flush phase)
- Memory improvements (uses no function closures)
- Break $eval into $apply, $dispatch, $flush
- Introduced $watch and $observe

Breaks angular.equals() use === instead of ==
Breaks angular.scope() does not take parent as first argument
Breaks scope.$watch() takes scope as first argument
Breaks scope.$set(), scope.$get are removed
Breaks scope.$config is removed
Breaks $route.onChange callback has not "this" bounded
2011-08-02 01:00:03 +02:00
Vojta Jina
f39420e7d7 style(): fix couple of missing semi-colons 2011-07-27 22:24:07 +02:00
Di Peng
0782422d1f feat(angular.version): add angular.version
- placeholders are replaced with actual angular versions when doing
rake compile
2011-07-22 15:34:55 -07:00
Igor Minar
fe5240732d feat(strict mode): adding strict mode flag to all js files
the flag must be in all src and test files so that we get the benefit of
running in the strict mode even in jstd

the following script was used to modify all files:

for file in `find src test -name "*.js"`; do
  echo -e "'use strict';\n" > temp.txt
  cat $file >> temp.txt
  mv temp.txt $file
done
2011-07-18 12:12:55 -07:00
Di Peng
bad62d87a1 fix:scope - reintroduce support for eager services
8cad231 broke $eager services

Problem is that the injector.eager function is not invoked when a new scope
is created. Added a test to make sure service is eagerly instantiated.

Closes #403
2011-06-23 08:06:24 -07:00
Di Peng
65b6e48742 test:angular.service - add tests for $inject 2011-06-23 07:56:58 -07:00
Misko Hevery
2a12f7dcaa Added nextUid() function for unified way of generating IDs in angular 2011-06-08 15:01:32 -07:00
Vojta Jina
aa64d37a23 Fix unit test in IE7 2011-06-02 08:55:10 -07:00
Igor Minar
0d2d7025e6 use special nodeName_ impl only for IE<9
apparently IE9 is one step closer to becoming a real browser by
treating xmlns-like ("foo:") prefixes in node names as part of the
node name.

fixes:
https://groups.google.com/forum/?lnk=srg#!topic/angular/TGdrV4GsL8U
2011-04-07 14:56:57 -07:00
Igor Minar
78a0f41058 encode query params correctly but not too agressively 2011-03-31 21:45:28 -07:00
Igor Minar
a4863d5244 correct size() impl for object's w/ 'length' prop
the original implementation returned incorrect value value for
objects with 'length' property.
2011-03-30 15:24:03 -07:00
Igor Minar
96a1df192a extend size() to take ownPropsOnly param
- extend size() to take size(obj, ownPropsOnly)
- add specs for size()
- update docs to mention string support
- use size() in ng:repeat

including the hasOwnProp check for all object doesn't create
significant perf penalty:
http://jsperf.com/dedicated-code-branch-for-hasownprop
2011-03-30 15:24:03 -07:00
Vojta Jina
9312bed472 Added missing semi-colons
So that my eclipse stops complaining...
2011-03-28 23:04:48 -07:00
Igor Minar
d304b0c3df fix failing autobind test on IE 2011-03-11 09:30:53 -08:00
Igor Minar
9d5c533791 ng:autobind now optionally takes element id
so it is possible to easily compile just a part of a document.

e.g.:

<html>
  <head>
    <title>partially compiled doc</title>
    <script src="angular.js" ng:autobind="compileThis"></script>
  </head>
  <body>
    this part won't be compiled: {{1+2}}
    <div id="compileThis" ng:init="i=0" ng:click="i = i+1">
      Click count: {{i}}
    </div>
  </body>
</html>
2011-03-11 08:45:43 -08:00
Igor Minar
7414e7b533 angularJsConfig now allows ng:autobind and #autobind value to be passed in 2011-03-11 08:45:16 -08:00
Igor Minar
945056b166 linking function should return bound scope
angular.compile()() returns {scope:scope, view:view},
this isn't useful at all and only makes tests more verbose.
Instead, this change makes the linking function return scope directly
and if anyone needs the linked dom there are two ways to do it
documented in angular.compile.

other changes:
- moved angular.compile docs to the compiler so that they are closer to
  the compiler
- fixed some typos and updated angular.compile docs with the new return
  value
2011-03-01 17:09:25 -08:00
Igor Minar
9e30baad3f resources should not over-encode chars in url path
- added encodeUriSegment that properly encodes only those chars
  that URI RFC requires us to encode
- modified Resource to use encodeUriSegment
2011-02-17 23:06:53 -08:00
Misko Hevery
c90abf057b Changed the angular.compile(element)(scope[, cloneAttachNode]) 2011-02-16 08:59:57 -05:00
Misko Hevery
ef4bb28be1 Change API angular.compile(element)([scope], [element/true]) 2011-02-16 01:03:12 -05:00
Misko Hevery
c2f2587a79 fixed example rendering, add tests for it. 2011-01-24 14:23:51 -08:00
Igor Minar
b0be87f663 fix for angular.Object.equals to handle equals({},null) 2011-01-13 07:55:31 -08:00
Igor Minar
142a985f33 Revert "Issue #51: Update extensionMap()"
This reverts commit 00ca67e4be.

Now that we don't have published services, we don't need to worryi
about this any more and in fact this behavior is confusing because
to override a service that has dependencies with a services with
no dependencies one must specify $inject:[] or else the old
dependencies will be injected.

Conflicts:

	src/Angular.js
	test/AngularSpec.js
2011-01-07 12:02:45 -08:00
Misko Hevery
807d8c92b3 removed dissabled tests which are now outdated 2011-01-06 14:51:44 -08:00
Igor Minar
b2631f6170 rename scope.$inject to scope.$service
see changelog diff for more info
2011-01-04 18:04:00 -08:00
Misko Hevery
5a8ad8fe32 Closes #170. Corrected the behavior of select when options are ng:repeated
- Delete $postEval method, as it was a hack
2010-12-02 22:45:57 -08:00
Igor Minar
264f960800 added spec for auto bootstrap with #autobind 2010-11-09 19:58:42 -08:00
Igor Minar
1a43f36e23 Add isDate method + fix old code 2010-11-08 22:49:29 -08:00
Vojta Jina
f3ac2cd434 Update AngularSpec tests to use BDD style - jasmine expect 2010-11-07 14:42:04 -08:00
Vojta Jina
7779630989 Added tests for angular.service
- should allow to override a service
- should preserve angular properties on override
- should not preserve non-angular properties on override
2010-11-07 14:42:03 -08:00
Vojta Jina
00ca67e4be Issue #51: Update extensionMap()
If user override existing extension, angular properties ($) will be preserved.

This piece of logic could be refactored into separate method:
Something like we have extend(), addMissingProperties() - I can't find a name
for this method...

Closes #51
2010-11-07 14:42:03 -08:00
Elliott Sprehn
40d7e66f40 Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.

ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner

$result is also an object tree result.

The permitted formats are html,json,xml,object.

If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.

<script src="angular-scenario.js" ng:scenario-output="xml,json">

- Added element(...).count() that returns the number of matching elements for the selector.

- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.

- Added toBe() matcher that does strict equality with ===

- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.

- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.

Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.

Events:
  RunnerBegin
  SpecBegin(spec)
  StepBegin(spec, step)
  StepError(spec, step, error)
  StepFailure(spec, step, error)
  StepEnd(spec, step)
  SpecError(spec, step, error)
  SpecEnd(spec)
  RunnerEnd

- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.

- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-26 15:17:57 -07:00
Misko Hevery
4fdab37659 create HTML sanitizer to allow inclusion of untrusted HTML in safe manner.
Sanitization works in two phases:
 1) We parse the HTML into sax-like events (start, end, chars).
    HTML parsing is very complex, and so it may very well be that what
    most browser consider valid HTML may not pares properly here,
    but we do best effort. We treat this parser as untrusted.
 2) We have safe sanitizeWriter which treats its input (start, end, chars)
    as untrusted content and escapes everything. It only allows elements
    in the whitelist and only allows attributes which are whitelisted.
    Any attribute value must not start with 'javascript:'. This check
    is performed after escaping for entity (&xAB; etc..) and ignoring
    any whitespace.

 - Correct linky filter to use safeHtmlWriter
 - Correct html filter to use safeHtmlWriter

Close #33; Close #34
2010-10-26 13:41:07 -07:00