Skip to content

Commit

Permalink
Replace new with createElement in demos to avoid errors in P3 [sk…
Browse files Browse the repository at this point in the history
…ip ci] (#152)

* Replace `new` with `createElement` in demos to avoid errors in P3
  • Loading branch information
manolo authored and yuriy-fix committed Aug 24, 2018
1 parent 7cbc2ca commit 0b2c824
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions demo/dropdown-menu-basic-demos.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ <h3>Basic Usage</h3>
window.addDemoReadyListener('#dropdown-menu-list-box-basic', function(document) {
document.querySelector('vaadin-dropdown-menu').renderer = function(root) {
// create the <vaadin-list-box>
const listBox = new Vaadin.ListBoxElement();
const listBox = window.document.createElement('vaadin-list-box');
// append 3 <vaadin-item> elements
['Jose', 'Manolo', 'Pedro'].forEach(function(name) {
const item = new Vaadin.ItemElement();
const item = window.document.createElement('vaadin-item');
item.textContent = name;
listBox.appendChild(item);
});
Expand Down Expand Up @@ -58,7 +58,7 @@ <h3>Configuring the Dropdown</h3>
window.addDemoReadyListener('#dropdown-menu-list-box-configuring', function(document) {
const appendItems = function(listBox, items) {
items.forEach(function(row) {
const item = new Vaadin.ItemElement();
const item = window.document.createElement('vaadin-item');
item.textContent = row.textContent;
if (row.value) {
item.setAttribute('value', row.value);
Expand All @@ -68,27 +68,27 @@ <h3>Configuring the Dropdown</h3>
};

document.querySelector('vaadin-dropdown-menu[placeholder]').renderer = function(root) {
const listBox = new Vaadin.ListBoxElement();
const listBox = window.document.createElement('vaadin-list-box');
appendItems(listBox, [{textContent: 'Option one'}, {textContent: 'Option two'}]);
root.appendChild(listBox);
};

document.querySelector('vaadin-dropdown-menu[disabled]').renderer = function(root) {
const listBox = new Vaadin.ListBoxElement();
const listBox = window.document.createElement('vaadin-list-box');
appendItems(listBox, [{textContent: 'Option one'}]);
root.appendChild(listBox);
};

document.querySelector('vaadin-dropdown-menu[readonly]').renderer = function(root) {
const listBox = new Vaadin.ListBoxElement();
const listBox = window.document.createElement('vaadin-list-box');
appendItems(listBox, [{textContent: 'Option one'}]);
root.appendChild(listBox);
};

document.querySelector('vaadin-dropdown-menu[required]').renderer = function(root) {
const listBox = new Vaadin.ListBoxElement();
const listBox = window.document.createElement('vaadin-list-box');
// un-selectable <vaadin-item> to highlight required state
const select = new Vaadin.ItemElement();
const select = window.document.createElement('vaadin-item');
select.textContent = 'Select an option';
select.setAttribute('disabled', '');
select.setAttribute('value', '');
Expand Down Expand Up @@ -119,15 +119,15 @@ <h3>Customize the Label of Selected Value</h3>
<script>
window.addDemoReadyListener('#dropdown-menu-list-box-custom-label', function(document) {
document.querySelector('vaadin-dropdown-menu').renderer = function(root) {
const listBox = new Vaadin.ListBoxElement();
const listBox = window.document.createElement('vaadin-list-box');
const items = [
{label: '', textContent: 'Other'},
{label: 'ES', textContent: 'Spanish'},
{label: 'FI', textContent: 'Finnish'},
{label: 'EN', textContent: 'English'}
];
items.forEach(function(row) {
const item = new Vaadin.ItemElement();
const item = window.document.createElement('vaadin-item');
item.textContent = row.textContent;
item.setAttribute('label', row.label);
listBox.appendChild(item);
Expand Down
6 changes: 3 additions & 3 deletions demo/dropdown-menu-validation-demos.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ <h3>Using as a Form Field</h3>
];

document.querySelector('vaadin-dropdown-menu').renderer = function(root) {
const listBox = new Vaadin.ListBoxElement();
const listBox = window.document.createElement('vaadin-list-box');

const select = new Vaadin.ItemElement();
const select = window.document.createElement('vaadin-item');
select.textContent = 'Select your title';
select.setAttribute('value', '');
listBox.appendChild(select);
Expand All @@ -49,7 +49,7 @@ <h3>Using as a Form Field</h3>
listBox.appendChild(divider);

items.forEach(function(row) {
const item = new Vaadin.ItemElement();
const item = window.document.createElement('vaadin-item');
item.textContent = row.textContent;
if (row.value) {
item.setAttribute('value', row.value);
Expand Down

0 comments on commit 0b2c824

Please sign in to comment.