Skip to content

Commit

Permalink
allow elements with null parentNode in and bugfix to route integratio…
Browse files Browse the repository at this point in the history
…n test
  • Loading branch information
Tobias Bosch committed Apr 24, 2013
1 parent 6815e40 commit 6db01ab
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ module.exports = function(grunt) {
options: {
configFile: 'testacular.conf.js',
singleRun: false,
browsers: [],
browsers: ['PhantomJS'],
keepalive: false
}
},
Expand Down
4 changes: 3 additions & 1 deletion compiled/jquery-mobile-angular-adapter-standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -35896,7 +35896,9 @@ factory(window.jQuery, window.angular);
return callback();
} finally {
if (oldParentNode !== document) {
oldParentNode.appendChild(node);
if (oldParentNode) {
oldParentNode.appendChild(node);
}
// Don't use remove, as this would destroy the page widget also,
// but we want to cache it!
emptyPage[0].parentNode.removeChild(emptyPage[0]);
Expand Down
2 changes: 1 addition & 1 deletion compiled/jquery-mobile-angular-adapter-standalone.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion compiled/jquery-mobile-angular-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,9 @@ factory(window.jQuery, window.angular);
return callback();
} finally {
if (oldParentNode !== document) {
oldParentNode.appendChild(node);
if (oldParentNode) {
oldParentNode.appendChild(node);
}
// Don't use remove, as this would destroy the page widget also,
// but we want to cache it!
emptyPage[0].parentNode.removeChild(emptyPage[0]);
Expand Down
2 changes: 1 addition & 1 deletion compiled/jquery-mobile-angular-adapter.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/integration/compileIntegration.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@
return callback();
} finally {
if (oldParentNode !== document) {
oldParentNode.appendChild(node);
if (oldParentNode) {
oldParentNode.appendChild(node);
}
// Don't use remove, as this would destroy the page widget also,
// but we want to cache it!
emptyPage[0].parentNode.removeChild(emptyPage[0]);
Expand Down
75 changes: 47 additions & 28 deletions test/devSnippetPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,62 @@
<script src="../lib/angular.js"></script>

<script src="../compiled/jquery-mobile-angular-adapter.js"></script>
<style>
.map {
width: 400px;
height: 375px;
border: 1px solid #777777;
}
</style>
<script src="https://raw.github.com/angular-ui/angular-ui/master/build/angular-ui.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
</style>

<script>
var mod = angular.module("ngm", []);
mod.controller("MainCtrl", function($scope, $location) {
$scope.click = function() {
$location.routeOverride({jqmOptions: {transition: 'pop'}});
$location.url('#page2');
};
});
var app = angular.module("app", ['ui']);

app.controller("MapCtrl",function ($scope) {
$scope.myMarkers = [];
$scope.addMarker = function($event) {
$scope.myMarkers.push(new google.maps.Marker({
map: $scope.myMap,
position: $event.latLng
}));
};


$scope.mapOptions = {
center: new google.maps.LatLng(46.227638, 2.213749),
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP
};

$scope.openMarkerInfo = function(marker) {
$scope.myInfoWindow.open($scope.myMap, marker);
};



});
</script>

</head>
<body ng-app="ngm">
<div id="main" data-role="page" ng-controller="MainCtrl">
<div data-role="header">
<h1>Page1</h1>
</div>
<body ng-app="app">
<div id="main" data-role="page" ng-controller="MapCtrl">
<div data-role="content">

<!--
<a id="test" href="#page2">Page2</a>
<a onclick="$('#test')[0].click()">Goto Page2 via Link before</a>
-->
<a ng-click="click()">Click me</a>


<div ng-repeat="marker in myMarkers" ui-map-marker="myMarkers[$index]"
ui-event="{'map-click': 'openMarkerInfo(marker)'}">
</div>

<div ui-map-info-window="myInfoWindow">Hello gentleman !</div>

<div id="map_canvas" ui-map="myMap" class="map"
ui-options="mapOptions" ui-event="{'map-click': 'addMarker($event)'}"></div>

</div>
</div>

<div data-role="page" id="page2">
<div data-role="header">
<h1>Page2</h1>
</div>
<div data-role="content">

<a href="#main">Page1</a>
</div>
</div>

</body>
</html>
5 changes: 3 additions & 2 deletions test/ui/integration/ngmRoutingUiSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ describe("ngmRouting", function () {
});

describe('scroll position', function() {
var bottomScrollPos;
var bottomScrollPos, initScrollPos;
uit.url(baseUrl+"#start");
uit.append(function($) {
var longText = new Array(500).join('<p>Hello</p>'),
Expand All @@ -572,6 +572,7 @@ describe("ngmRouting", function () {
}
beforeEach(function() {
uit.runs(function($location,$rootScope) {
initScrollPos = scrollPos();
scrollDown();
bottomScrollPos = scrollPos();
});
Expand All @@ -584,7 +585,7 @@ describe("ngmRouting", function () {
uit.runs(function($, $location,$rootScope) {
$location.url("#start");
$rootScope.$apply();
expect(scrollPos()).toBe($.mobile.defaultHomeScroll);
expect(scrollPos()).toBe(initScrollPos);
});
});
it('restores the scroll position when going back', function() {
Expand Down
7 changes: 7 additions & 0 deletions test/unit/integration/compileIntegrationUnitSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ describe('compileIntegrationUnit', function () {
expect(spy.callCount).toBe(1);
});

it("should allow to compile elements that have a parent that does not belong to the document nor document fragment", inject(function($compile, $rootScope) {
var el = $(document.createElement("div"));
el.html('<span></span>');
expect(el[0].parentNode).toBe(null);
$compile(el.contents())($rootScope);
}));

it("should stamp stateful jqm widgets using the jqm widgets", function () {
// Note: button is a stateful widget
var spy = testutils.spyOnJq('button').andCallThrough();
Expand Down

0 comments on commit 6db01ab

Please sign in to comment.