-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Steven Orvell
committed
Oct 28, 2015
1 parent
f7d86e9
commit 35a1b94
Showing
3 changed files
with
167 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
<!doctype html> | ||
<!-- | ||
@license | ||
Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | ||
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"> | ||
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script> | ||
<script src="../../../web-component-tester/browser.js"></script> | ||
<link rel="import" href="../../polymer.html"> | ||
</head> | ||
<body> | ||
|
||
<dom-module id="has-whitespace"> | ||
|
||
<template> <div>A</div> <div>B</div> </template> | ||
|
||
<script> | ||
HTMLImports.whenReady(function() { | ||
Polymer({ | ||
is: 'has-whitespace' | ||
}); | ||
}); | ||
</script> | ||
|
||
</dom-module> | ||
|
||
|
||
|
||
<dom-module id="no-whitespace"> | ||
|
||
<template strip-whitespace> | ||
<div>A</div> | ||
<div>A</div> | ||
<div>B</div> | ||
</template> | ||
|
||
<script> | ||
HTMLImports.whenReady(function() { | ||
Polymer({ | ||
is: 'no-whitespace' | ||
}); | ||
}); | ||
</script> | ||
|
||
</dom-module> | ||
|
||
|
||
|
||
<dom-module id="no-whitespace-style"> | ||
|
||
<template strip-whitespace> | ||
<style> | ||
:host { | ||
display: block; | ||
} | ||
</style> | ||
<div>A</div> | ||
<div>B</div> | ||
</template> | ||
|
||
<script> | ||
HTMLImports.whenReady(function() { | ||
Polymer({ | ||
is: 'no-whitespace-style' | ||
}); | ||
}); | ||
</script> | ||
|
||
</dom-module> | ||
|
||
<dom-module id="no-whitespace-nested"> | ||
|
||
<template strip-whitespace> | ||
<div> | ||
<div>A</div> | ||
</div> | ||
<div> | ||
<div>B</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
HTMLImports.whenReady(function() { | ||
Polymer({ | ||
is: 'no-whitespace-nested' | ||
}); | ||
}); | ||
</script> | ||
|
||
</dom-module> | ||
|
||
|
||
|
||
<script> | ||
|
||
suite('polymer: template whitespace', function() { | ||
|
||
test('template stamped with whitespace preserved', function() { | ||
var el = document.createElement('has-whitespace'); | ||
assert.equal(Polymer.dom(el.root).childNodes.length, 5); | ||
assert.equal(Polymer.dom(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(Polymer.dom(el.root).childNodes.length, 3); | ||
assert.equal(Polymer.dom(el.root).childNodes.length, Polymer.dom(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); | ||
assert.equal(Polymer.dom(el.root).childNodes.length, 2); | ||
assert.equal(Polymer.dom(el.root).childNodes.length, Polymer.dom(el.root).children.length); | ||
}); | ||
|
||
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(Polymer.dom(el.root).childNodes.length, 2); | ||
assert.equal(Polymer.dom(el.root).childNodes.length, Polymer.dom(el.root).children.length); | ||
assert.equal(Polymer.dom(el.root).childNodes[0].childNodes.length, Polymer.dom(el.root).childNodes[0].children.length); | ||
assert.equal(Polymer.dom(el.root).childNodes[1].childNodes.length, Polymer.dom(el.root).childNodes[1].children.length); | ||
}); | ||
|
||
}); | ||
|
||
</script> | ||
</body> | ||
</html> |