fixed xhtml compatibility, fix console in chrome

This commit is contained in:
Misko Hevery 2010-07-20 16:55:32 -07:00
parent 7e96af0fdd
commit bebfbeac0a
9 changed files with 31 additions and 32 deletions

View file

@ -2,19 +2,9 @@
<html>
<head>
<script type="text/javascript"
src="http://angularjs.org/ng/js/angular-debug.js"></script>
<script type="text/javascript">
(function(window, previousOnLoad){
window.onload = function(){
try {
(previousOnLoad||angular.noop)();
} catch(e) {}
angular.compile(window.document).$init();
};
})(window, window.onload);
</script>
src="../src/angular-bootstrap.js#autobind"></script>
</head>
<body>
<body ng:init="$window.$root = this">
Hello {{'World'}}!
</body>
</html>

View file

@ -22,7 +22,7 @@ var consoleNode,
angularTextMarkup = extensionMap(angular, 'textMarkup'),
angularAttrMarkup = extensionMap(angular, 'attrMarkup'),
angularDirective = extensionMap(angular, 'directive'),
angularWidget = extensionMap(angular, 'widget'),
angularWidget = extensionMap(angular, 'widget', lowercase),
angularValidator = extensionMap(angular, 'validator'),
angularFilter = extensionMap(angular, 'filter'),
angularFormatter = extensionMap(angular, 'formatter'),
@ -84,9 +84,10 @@ function inherit(parent, extra) {
function noop() {}
function identity($) {return $;}
function extensionMap(angular, name) {
function extensionMap(angular, name, transform) {
var extPoint;
return angular[name] || (extPoint = angular[name] = function (name, fn, prop){
name = (transform || identity)(name);
if (isDefined(fn)) {
extPoint[name] = extend(fn, prop || {});
}
@ -419,7 +420,7 @@ function angularInit(config){
function angularJsConfig(document) {
var filename = /(.*)\/angular(-(.*))?.js(#(.*))?/,
scripts = document.getElementsByTagName("SCRIPT"),
scripts = document.getElementsByTagName("script"),
match;
for(var j = 0; j < scripts.length; j++) {
match = (scripts[j].src || "").match(filename);

View file

@ -18,6 +18,8 @@ extend(angular, {
'foreach': foreach,
'noop':noop,
'bind':bind,
'toJson': toJson,
'fromJson': fromJson,
'identity':identity,
'isUndefined': isUndefined,
'isDefined': isDefined,

View file

@ -121,20 +121,25 @@ Compiler.prototype = {
descend: function(value){ if(isDefined(value)) descend = value; return descend;},
directives: function(value){ if(isDefined(value)) directives = value; return directives;}
};
priority = element.attr('ng:eval-order') || priority || 0;
try {
priority = element.attr('ng:eval-order') || priority || 0;
} catch (e) {
// for some reason IE throws error under some weird circumstances. so just assume nothing
priority = priority || 0;
}
if (isString(priority)) {
priority = PRIORITY[uppercase(priority)] || 0;
}
template = new Template(priority);
eachAttribute(element, function(value, name){
if (!widget) {
if (widget = self.widgets['@' + name]) {
if (widget = self.widgets('@' + name)) {
widget = bind(selfApi, widget, value, element);
}
}
});
if (!widget) {
if (widget = self.widgets[nodeName(element)]) {
if (widget = self.widgets(nodeName(element))) {
widget = bind(selfApi, widget, element);
}
}

View file

@ -12,6 +12,7 @@ var angularGlobal = {
};
var angularCollection = {
'copy': copy,
'size': size,
'equals': equals
};

View file

@ -65,13 +65,13 @@ angularService("$location", function(browser){
}, {inject: ['$browser']});
angularService("$log", function($window){
var console = $window.console,
log = console && console.log || noop;
var console = $window.console || {log: noop, warn: noop, info: noop, error: noop},
log = console.log || noop;
return {
log: log,
warn: console && console.warn || log,
info: console && console.info || log,
error: console && console.error || log
log: bind(console, log),
warn: bind(console, console.warn || log),
info: bind(console, console.info || log),
error: bind(console, console.error || log)
};
}, {inject:['$window']});

View file

@ -222,16 +222,16 @@ function inputWidgetSelector(element){
return INPUT_TYPE[lowercase(element[0].type)] || noop;
}
angularWidget('INPUT', inputWidgetSelector);
angularWidget('TEXTAREA', inputWidgetSelector);
angularWidget('BUTTON', inputWidgetSelector);
angularWidget('SELECT', function(element){
angularWidget('input', inputWidgetSelector);
angularWidget('textarea', inputWidgetSelector);
angularWidget('button', inputWidgetSelector);
angularWidget('select', function(element){
this.descend(true);
return inputWidgetSelector.call(this, element);
});
angularWidget('NG:INCLUDE', function(element){
angularWidget('ng:include', function(element){
var compiler = this,
srcExp = element.attr("src"),
scopeExp = element.attr("scope") || '';
@ -265,7 +265,7 @@ angularWidget('NG:INCLUDE', function(element){
}
});
var ngSwitch = angularWidget('NG:SWITCH', function (element){
var ngSwitch = angularWidget('ng:switch', function (element){
var compiler = this,
watchExpr = element.attr("on"),
usingExpr = (element.attr("using") || 'equals'),

View file

@ -22,7 +22,7 @@ describe('compiler', function(){
};
textMarkup = [];
attrMarkup = [];
widgets = {};
widgets = extensionMap({}, 'widget');
compiler = new Compiler(textMarkup, attrMarkup, directives, widgets);
compile = function(html){
var e = jqLite("<div>" + html + "</div>");

View file

@ -407,7 +407,7 @@ describe("widget", function(){
it("should match sandwich ids", function(){
var scope = {};
var match = angular.widget['NG:SWITCH'].route.call(scope, '/a/123/b', '/a/:id');
var match = angular.widget('NG:SWITCH').route.call(scope, '/a/123/b', '/a/:id');
expect(match).toBeFalsy();
});