Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: angular/angular
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: dylanb/angular
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 3 commits
  • 5 files changed
  • 1 contributor

Commits on Mar 3, 2015

  1. Copy the full SHA
    4435e5f View commit details

Commits on Mar 4, 2015

  1. merge upstream

    dylanb committed Mar 4, 2015
    Copy the full SHA
    b353e67 View commit details

Commits on Mar 6, 2015

  1. Copy the full SHA
    315d0de View commit details
130 changes: 130 additions & 0 deletions modules/examples/e2e_test/menu/menu_spec.es6
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
var testUtil = require('angular2/src/test_lib/e2e_util');
var wd = require('selenium-webdriver');

describe('menu', function () {
afterEach(testUtil.verifyNoBrowserErrors);
describe('Menu: dynamic reflection', function() {
var URL = 'examples/src/menu/menu.html';

it('should insert the menu into the DOM', function() {
browser.get(URL);

expect(getMenuLength('#mymenu')).toBe(1);
});
it('should support arrow key navigation that wraps around at the menubar level', function () {
browser.get(URL);
setFocusIntoMenu();
expect(getMenuFocusedText()).toBe('One');
sendMenuKey(wd.Key.RIGHT);
expect(getMenuFocusedText()).toBe('Two');
sendMenuKey(wd.Key.RIGHT);
expect(getMenuFocusedText()).toBe('Three');
sendMenuKey(wd.Key.RIGHT);
expect(getMenuFocusedText()).toBe('Überhaupt');
// wrap
sendMenuKey(wd.Key.RIGHT);
expect(getMenuFocusedText()).toBe('One');
// wrap back
sendMenuKey(wd.Key.LEFT);
expect(getMenuFocusedText()).toBe('Überhaupt');
});
it('should support arrow key navigation that opens and closes the sub-menus, sub menus should wrap', function () {
browser.get(URL);
setFocusIntoMenu();
expect(getMenuFocusedText()).toBe('One');
sendMenuKey(wd.Key.RIGHT);
expect(getMenuFocusedText()).toBe('Two');
// open and focus
sendMenuKey(wd.Key.DOWN);
expect(getMenuFocusedText()).toBe('Two One');
// open and focus
sendMenuKey(wd.Key.RIGHT);
expect(getMenuFocusedText()).toBe('Two One One');
// close
sendMenuKey(wd.Key.ESCAPE);
expect(getMenuFocusedText()).toBe('Two One');

// Test wrapping of the sub-menu
sendMenuKey(wd.Key.DOWN);
expect(getMenuFocusedText()).toBe('Two Two');
sendMenuKey(wd.Key.DOWN);
expect(getMenuFocusedText()).toBe('Two Three');
sendMenuKey(wd.Key.DOWN);
expect(getMenuFocusedText()).toBe('Two Four');
sendMenuKey(wd.Key.DOWN);
expect(getMenuFocusedText()).toBe('Two One');
sendMenuKey(wd.Key.UP);
expect(getMenuFocusedText()).toBe('Two Four');

// close
sendMenuKey(wd.Key.ESCAPE);
expect(getMenuFocusedText()).toBe('Two');
});
it('should support arrow key navigation and enter that opens the sub-menus', function () {
browser.get(URL);
setFocusIntoMenu();
expect(getMenuFocusedText()).toBe('One');
sendMenuKey(wd.Key.RIGHT);
expect(getMenuFocusedText()).toBe('Two');
// open and focus
sendMenuKey(wd.Key.ENTER);
expect(getMenuFocusedText()).toBe('Two One');
// open and focus
sendMenuKey(wd.Key.ENTER);
expect(getMenuFocusedText()).toBe('Two One One');
// close
sendMenuKey(wd.Key.LEFT);
expect(getMenuFocusedText()).toBe('Two One');
// close
sendMenuKey(wd.Key.LEFT);
expect(getMenuFocusedText()).toBe('Two');
});
it('should support keypress navigation that focusses the next item with a 1st character that matches the key pressed', function () {
browser.get(URL);
setFocusIntoMenu();
expect(getMenuFocusedText()).toBe('One');
sendMenuKey('t');
expect(getMenuFocusedText()).toBe('Two');
sendMenuKey('t');
expect(getMenuFocusedText()).toBe('Three');
sendMenuKey('t');
expect(getMenuFocusedText()).toBe('Two');
});
it('should support enter selecting a menu item', function () {
browser.get(URL);
setFocusIntoMenu();
expect(getMenuFocusedText()).toBe('One');
// wrap
sendMenuKey(wd.Key.LEFT);
expect(getMenuFocusedText()).toBe('Überhaupt');
sendMenuKey(wd.Key.ENTER);
expect(getURLFragment()).toBe('#four');
});
});
});

function getMenuLength(innerSelector) {
return browser.executeScript('return document.querySelector("menu-app").shadowRoot.querySelectorAll("'+innerSelector+'").length');
}

function getMenuFocusedText() {
return browser.executeScript(
`var sr = document.querySelector("menu-app").shadowRoot;
if (sr.activeElement.querySelector('li')) {
return sr.activeElement.firstChild.textContent.trim();
} else {
return sr.activeElement.querySelector('a').firstChild.textContent.trim();
}`);
}

function setFocusIntoMenu() {
browser.findElement(By.tagName('body')).sendKeys('\t');
}

function sendMenuKey(keys) {
browser.findElement(By.tagName('menu-app')).sendKeys(keys);
}

function getURLFragment() {
return browser.executeScript('return window.location.hash;');
}
136 changes: 136 additions & 0 deletions modules/examples/src/menu/menu.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
.offscreen {
border: 0;
clip: rect(0 0 0 0);
clip: rect(0, 0, 0, 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
width: 1px;
position: absolute;
}

.a11yfy-top-level-menu li:focus {
outline: 2px dotted black;
z-index: 100;
}
.a11yfy-third-level-menu {
position: absolute;
top: 0;
right: -150px;
width: 150px;
list-style: none;
padding: 0;
margin: 0;
display: none;
}

.a11yfy-mega .a11yfy-third-level-menu {
position: static;
top: auto;
right: auto;
width: auto;
display:block;
}

.a11yfy-third-level-menu > li {
min-height: 30px;
background: #999999;
}
.a11yfy-third-level-menu > li:hover,
.a11yfy-third-level-menu > li:focus {
background: #CCCCCC;
color: #000000;
}

.a11yfy-second-level-menu {
position: absolute;
top: 30px;
left: 0;
width: 150px;
list-style: none;
padding: 0;
margin: 0;
display: none;
}

.a11yfy-second-level-menu > li {
min-height: 30px;
background: #999999;
}
.a11yfy-second-level-menu > li:hover,
.a11yfy-second-level-menu > li:focus {
background: #CCCCCC;
color: #000000;
}

.a11yfy-top-level-menu {
list-style: none;
padding: 0;
margin: 0;
}

.a11yfy-top-level-menu > li {
position: relative;
float: left;
height: 30px;
width: 150px;
background: #999999;
}
.a11yfy-top-level-menu > li:hover,
.a11yfy-top-level-menu > li:focus {
background: #CCCCCC;
color: #000000;
}

.a11yfy-top-level-menu li:hover > ul,
.a11yfy-top-level-menu li.open > ul {
display: inline;
}

li.a11yfy-has-submenu:after {
content: "\2b46";
}
.a11yfy-mega li.a11yfy-has-submenu:after {
content: none;
}

ul.a11yfy-top-level-menu>li.a11yfy-has-submenu:after {
content: "\290b";
}
.a11yfy-two_col {
width:300px;
}

.a11yfy-three_col {
width: 450px;
}

.a11yfy-four_col {
width: 600px;
}

.a11yfy-col {
display:inline;
float:left;
width: 140px;
}
.a11yfy-top-level-menu a {
text-decoration: none;
color: #FFFFFF;
}

.a11yfy-top-level-menu li:focus>a, .a11yfy-top-level-menu li:hover>a {
color: #000000;
}

.a11yfy-top-level-menu li {
font: bold 14px Arial, Helvetica, sans-serif;
color: #FFFFFF;
text-decoration: none;
padding: 0 0 0 10px;

display: block;
line-height: 30px;
}
.a11yfy-top-level-menu li:hover { color: #000000; }
12 changes: 12 additions & 0 deletions modules/examples/src/menu/menu.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html>
<head>
<title>Menu Angular 2.0 (Reflection)</title>
</head>
<body>
<menu-app>
Loading...
</menu-app>
$SCRIPTS$
</body>
</html>
8 changes: 8 additions & 0 deletions modules/examples/src/menu/menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as app from './menu_common';
import {reflector} from 'angular2/src/reflection/reflection';
import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities';

export function main() {
reflector.reflectionCapabilities = new ReflectionCapabilities();
app.main();
}
Loading