2016-08-09 10:28:56 -07:00
|
|
|
<!doctype html>
|
|
|
|
|
<!--
|
|
|
|
|
@license
|
2017-03-03 16:54:36 -08:00
|
|
|
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
|
2016-08-09 10:28:56 -07:00
|
|
|
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
|
|
|
|
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
|
|
|
|
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
|
|
|
|
Code distributed by Google as part of the polymer project is also
|
|
|
|
|
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
|
|
|
-->
|
|
|
|
|
<html>
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="utf-8">
|
2018-04-26 15:43:17 -07:00
|
|
|
<script src="../../node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
|
2018-04-19 16:27:06 -07:00
|
|
|
<script src="wct-browser-config.js"></script>
|
2018-04-19 18:19:39 -07:00
|
|
|
<script src="../../node_modules/wct-browser-legacy/browser.js"></script>
|
2018-04-13 16:40:26 -07:00
|
|
|
<script type="module" src="../../polymer-legacy.js"></script>
|
2016-08-09 10:28:56 -07:00
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
|
|
<dom-module id="has-whitespace">
|
|
|
|
|
|
|
|
|
|
<template> <div>A</div> <div>B</div> </template>
|
|
|
|
|
|
2018-04-13 16:40:26 -07:00
|
|
|
<script type="module">
|
2018-04-19 17:06:55 -07:00
|
|
|
import { Polymer } from '../../polymer-legacy.js';
|
2018-04-13 16:40:26 -07:00
|
|
|
Polymer({
|
|
|
|
|
is: 'has-whitespace'
|
|
|
|
|
});
|
|
|
|
|
</script>
|
2016-08-09 10:28:56 -07:00
|
|
|
|
|
|
|
|
</dom-module>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<dom-module id="no-whitespace">
|
|
|
|
|
|
|
|
|
|
<template strip-whitespace>
|
|
|
|
|
<div>A</div>
|
|
|
|
|
<div>A</div>
|
|
|
|
|
<div>B</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2018-04-13 16:40:26 -07:00
|
|
|
<script type="module">
|
2018-04-19 17:06:55 -07:00
|
|
|
import { Polymer } from '../../polymer-legacy.js';
|
2018-04-13 16:40:26 -07:00
|
|
|
Polymer({
|
|
|
|
|
is: 'no-whitespace'
|
|
|
|
|
});
|
|
|
|
|
</script>
|
2016-08-09 10:28:56 -07:00
|
|
|
|
|
|
|
|
</dom-module>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<dom-module id="no-whitespace-style">
|
|
|
|
|
|
|
|
|
|
<template strip-whitespace>
|
|
|
|
|
<style>
|
|
|
|
|
:host {
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
<div>A</div>
|
|
|
|
|
<div>B</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2018-04-13 16:40:26 -07:00
|
|
|
<script type="module">
|
2018-04-19 17:06:55 -07:00
|
|
|
import { Polymer } from '../../polymer-legacy.js';
|
2018-04-13 16:40:26 -07:00
|
|
|
Polymer({
|
|
|
|
|
is: 'no-whitespace-style'
|
|
|
|
|
});
|
|
|
|
|
</script>
|
2016-08-09 10:28:56 -07:00
|
|
|
|
|
|
|
|
</dom-module>
|
|
|
|
|
|
|
|
|
|
<dom-module id="no-whitespace-nested">
|
|
|
|
|
|
|
|
|
|
<template strip-whitespace>
|
|
|
|
|
<div>
|
|
|
|
|
<div>A</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<div>B</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2018-04-13 16:40:26 -07:00
|
|
|
<script type="module">
|
2018-04-19 17:06:55 -07:00
|
|
|
import { Polymer } from '../../polymer-legacy.js';
|
2018-04-13 16:40:26 -07:00
|
|
|
Polymer({
|
|
|
|
|
is: 'no-whitespace-nested'
|
|
|
|
|
});
|
|
|
|
|
</script>
|
2016-08-09 10:28:56 -07:00
|
|
|
|
|
|
|
|
</dom-module>
|
|
|
|
|
|
|
|
|
|
<dom-module id="no-whitespace-binding">
|
|
|
|
|
|
|
|
|
|
<template strip-whitespace>
|
|
|
|
|
|
|
|
|
|
<div id="text">{{text}}</div>
|
|
|
|
|
<div id="attr" attr$="{{attr}}">
|
|
|
|
|
<div>A</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<div>B</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div id="compound"> {{a}} {{b}} </div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2018-04-13 16:40:26 -07:00
|
|
|
<script type="module">
|
2018-04-19 17:06:55 -07:00
|
|
|
import { Polymer } from '../../polymer-legacy.js';
|
2018-04-13 16:40:26 -07:00
|
|
|
Polymer({
|
|
|
|
|
properties: {
|
|
|
|
|
text: {value: 'text'},
|
|
|
|
|
attr: {value: 'attr'},
|
|
|
|
|
a: {value: 'a'},
|
|
|
|
|
b: {value: 'b'}
|
|
|
|
|
},
|
|
|
|
|
is: 'no-whitespace-binding'
|
|
|
|
|
});
|
|
|
|
|
</script>
|
2016-08-09 10:28:56 -07:00
|
|
|
|
|
|
|
|
</dom-module>
|
|
|
|
|
|
2017-01-18 18:48:58 -08:00
|
|
|
<dom-module id="no-whitespace-repeat">
|
|
|
|
|
|
|
|
|
|
<template strip-whitespace>
|
|
|
|
|
|
|
|
|
|
<template is="dom-repeat" items="[[items]]">
|
|
|
|
|
<div></div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
2018-04-13 16:40:26 -07:00
|
|
|
<script type="module">
|
2018-04-19 17:06:55 -07:00
|
|
|
import { Polymer } from '../../polymer-legacy.js';
|
2018-04-13 16:40:26 -07:00
|
|
|
Polymer({
|
|
|
|
|
properties: {
|
|
|
|
|
items: {
|
|
|
|
|
value: function() { return [1, 2, 3];}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
is: 'no-whitespace-repeat'
|
|
|
|
|
});
|
|
|
|
|
</script>
|
2017-01-18 18:48:58 -08:00
|
|
|
|
|
|
|
|
</dom-module>
|
|
|
|
|
|
2016-08-09 10:28:56 -07:00
|
|
|
|
|
|
|
|
|
2018-04-13 16:40:26 -07:00
|
|
|
<script type="module">
|
|
|
|
|
import { flush } from '../../lib/utils/flush.js';
|
|
|
|
|
|
|
|
|
|
suite('polymer: template whitespace', function() {
|
|
|
|
|
|
|
|
|
|
test('template stamped with whitespace preserved', function() {
|
|
|
|
|
var el = document.createElement('has-whitespace');
|
|
|
|
|
document.body.appendChild(el);
|
|
|
|
|
assert.equal(el.root.childNodes.length, 5);
|
|
|
|
|
assert.equal(el.root.childNodes[0].nodeType, Node.TEXT_NODE);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('template stamped without whitespace when strip-template is used', function() {
|
|
|
|
|
var el = document.createElement('no-whitespace');
|
|
|
|
|
document.body.appendChild(el);
|
|
|
|
|
assert.equal(el.root.childNodes.length, 3);
|
|
|
|
|
assert.equal(el.root.childNodes.length, el.root.children.length);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('template including style stamped without whitespace when strip-template is used', function() {
|
|
|
|
|
var el = document.createElement('no-whitespace-style');
|
|
|
|
|
document.body.appendChild(el);
|
|
|
|
|
var c$ = Array.from(el.root.childNodes).filter(function(e) {
|
|
|
|
|
return e.localName != 'style';});
|
|
|
|
|
assert.equal(c$.length, 2);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('template with nested content stamped without whitespace when strip-template is used', function() {
|
|
|
|
|
var el = document.createElement('no-whitespace-nested');
|
|
|
|
|
document.body.appendChild(el);
|
|
|
|
|
assert.equal(el.root.childNodes.length, 2);
|
|
|
|
|
assert.equal(el.root.childNodes.length, el.root.children.length);
|
|
|
|
|
assert.equal(el.root.childNodes[0].childNodes.length, el.root.childNodes[0].children.length);
|
|
|
|
|
assert.equal(el.root.childNodes[1].childNodes.length, el.root.childNodes[1].children.length);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('template with nested content stamped without whitespace when strip-template is used', function() {
|
|
|
|
|
var el = document.createElement('no-whitespace-binding');
|
|
|
|
|
document.body.appendChild(el);
|
|
|
|
|
assert.equal(el.$.text.textContent, 'text');
|
|
|
|
|
assert.equal(el.$.attr.getAttribute('attr'), 'attr');
|
|
|
|
|
assert.equal(el.$.compound.textContent, ' a b ');
|
|
|
|
|
});
|
2017-01-18 18:48:58 -08:00
|
|
|
|
2018-04-13 16:40:26 -07:00
|
|
|
test('template with dom-repeat stamped without whitespace when strip-template is used', function() {
|
|
|
|
|
var el = document.createElement('no-whitespace-repeat');
|
|
|
|
|
document.body.appendChild(el);
|
|
|
|
|
flush();
|
|
|
|
|
assert.equal(el.shadowRoot.childNodes.length, 4);
|
2016-08-09 10:28:56 -07:00
|
|
|
});
|
|
|
|
|
|
2018-04-13 16:40:26 -07:00
|
|
|
});
|
2016-08-09 10:28:56 -07:00
|
|
|
</script>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|