What about 3rd party JavaScript? #AskPolymer -- Polycasts #44
Skills:
JavaScript Fundamentals70%
Key Takeaways
Addresses questions on mocking behaviors in tests and supporting ES2015 in Polymer
Full Transcript
PC2 intro take one marker hey there play casters Rob here welcome back to another segment of ask polymer the show where you send in questions on the various social media networks out there and I do my best to answer them okay our first question comes from danger Manley who asks for elements that contain iron Ajax uh how can we mock their behavior so interesting question there web component tester itself ships with a few clever tools that can perhaps help you out here the first is a function called stub element and you can use that to actually replace an element that is like inside of other elements you could say stub element iron a Jacks and then as the second argument you could pass in like fake iron a Jacks you can actually create your own mock element that'll swap in right before it does the unit test that is one approach uh the other is to use something like sinon's fake xhr server so that also ships with web component Tester the the sonon command is is there for you so you can create a a fake xhr server actually have it send back fake responses and that way you don't have to you know spin up a server yourself or anything to like feed your your test data you can just use this little mock server and feed data to iron Hax that way so uh two options there if you're curious we actually have a video that maybe goes a little bit more into this it's from a a talk at polymer Summit by one of our team members so you can check that out over here uh our team member Chris who created the stub element stuff uh he actually gave a whole talk on this stuff so go check that out if you're interested uh thank you danger for that awesome question okay our next question comes from Alan who asks if I'm using something like iron list I'm scrolling through thousands of items how do I know how do I detect when the user has scrolled to the bottom of the list so that is a very good question today it's a little tricky to do that but the team is building an element called iron scroll threshold so you can combine that with an iron list and that way use a little data binding and it'll alert you when the user has hit the bottom of the list that way you know if you have a million items in your list but you only want to load the first 100 at a time the user can scroll down to that first 100 then you can you know get that binding event you can then go lazy load another pack of 100 items and sort of keep going that way you can build like kind of a good infinite scrolling experience uh so yeah using iron scroll threshold I'll I'll link it down in the show notes and you can combine that with your iron list and hopefully get that kind of cool smooth infinite list experience that you're after all right our next question comes from Cody who asks how do I load external Javascript Frameworks into my components so this is sort of a tricky bit here uh I think Cody was asking how do I load like jQuery into my element so I can use it for selecting stuff inside of my component in general we recommend not trying to use things like jQuery inside of your element definitions it it creates two issues one it means that anybody using your component is going to have to also depend on jQuery but it also is tricky because jQuery right now doesn't really know how to work with Shadow Dom and so you could end up in weird situations where you're trying to select stuff and it's not quite working and it's not clear why so in general we recommend just sticking with vanilla JavaScript inside of your element for you know specking out its definition you can however depend on external libraries that do things like momentjs is a good example something that like converts time stamps for you things that aren't interacting with the Dom necessarily you can load those in using uh HTML Imports you can create an import for one of those libraries that just contains a script tag and Pull It in that way so that's totally acceptable but Frameworks that want to manipulate the Dom probably want to stay away from using those inside your element definition so uh thank you Cody for that question okay our next question comes from Tom who asks what should I keep in mind when styling CSS for web components so I think the main thing to keep in mind is you're working with Shadow Dom and if you're not familiar with it it can be sort of tricky because it creates this sort of Style bubble around around your components I think it's really useful to learn how to work with custom properties and how to work with CSS Mixon both of those are features which polymer uses pretty heavily to allow you to you know jump over Shadow boundaries and and style the internals of components without having to like violate encapsulation and know what's going on there uh internally directly so if you're not familiar with those things that I just said if that just sounded like a bunch of crazy words and you can go check out this guide over here that we've created on how you style the shadow Dom which we actually sometimes refer to as local Dom so the guide is styling local Dom you go check that out that'll explain custom properties that'll explain CSS Mixon and a lot of the things that you need to keep in mind when you're trying to style your first web components so uh thank you Tom for that question all right the last question comes from alos who he actually asked a lot of questions but he asked when are carbon elements coming and when will we get es6 with polymer so carbon elements we're still working on those we don't have a definitive release date for that just yet but we're hoping you know maybe in the next one or two quarters those should start to roll out es6 in polymer that's something that I think we really want to work on this year we want to make sure that uh everyone can write their component definitions using all the latest and greatest es6 syntax So within the team we are actually working on some tools which we're hoping to release again probably in the next couple quarters uh to let people start to use es6 with their component definitions so I know it's sort of a bummer to to say like you know it's coming wait on it but this is stuff that we actively working on right now we we just finished a bunch of meetings talking about both of these topics uh so look forward to more on both of those fronts in 2016 okay so uh thank you everybody who sent in questions lots of really great things this week if you out there if you yourself you got some questions for me you can leave them down below in the comments or you can ping us on a social network of your choosing at # askpolymer as always thank you so much for watching and I'll see you next time a lot of good questions today thank you everyone who sent in some stuff what why is everybody laughing take two thank you all who sent in some stuff sorry take three Special Agent Cody Weaver sounds like a cool detective name
Original Description
Today on #AskPolymer: how do I mock behaviors in my tests? Or know when the user has reached the bottom of a an iron-list? And hey! When are you guys going to start supporting ES2015 in Polymer???
Question 1:
https://twitter.com/DangerManley/status/673589812440539136
Polymer testing talk: https://www.youtube.com/watch?v=kX2INPJY4Y4
Question 2:
https://plus.google.com/+AlanChandler42/posts/DHMabWrah6k
iron-scroll-threshold https://github.com/PolymerElements/iron-scroll-threshold
Question 3:
https://goo.gl/xdFfUo
Question 4:
https://twitter.com/nylk/status/690590967603294210
Styling local DOM guide https://www.polymer-project.org/1.0/docs/devguide/styling.html
Question 5:
https://goo.gl/Z67hoK
Subscribe to the Chrome Developers channel here: https://goo.gl/WkxCU5
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Chrome for Developers · Chrome for Developers · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Polymer Performance Patterns (The Polymer Summit 2015)
Chrome for Developers
Polymer Power Tools (The Polymer Summit 2015)
Chrome for Developers
Chrome Dev Summit 2014 – Chrome Case Studies
Chrome for Developers
Web Directions Code 2015 round up
Chrome for Developers
Maintainable Code - HTTP203
Chrome for Developers
iron-ajax… wat?! -- Polycasts #26
Chrome for Developers
The Guardian - Supercharged
Chrome for Developers
ES2015 (next version of JavaScript), Totally Tooling Tips (S2 Ep1)
Chrome for Developers
#AskPolymer: Rob answers all the questions ever -- Polycasts #27
Chrome for Developers
The Future of JavaScript - HTTP203
Chrome for Developers
Data Binding 101 -- Polycasts #28
Chrome for Developers
The Guardian part 2 - Supercharged
Chrome for Developers
The Future of Web Audio: with Chris Wilson and Chris Lowis
Chrome for Developers
Chrome 46: New motion-path animations, client hints and service worker improvements
Chrome for Developers
Sublime Snippets, Totally Tooling Tips (S2 Ep2)
Chrome for Developers
#AskPolymer: How do you make the show? -- Polycasts #29
Chrome for Developers
Critical Path CSS, Totally Tooling Tips (S2 Mini Tip #1)
Chrome for Developers
Binding to Objects -- Polycasts #30
Chrome for Developers
Player FM - Supercharged
Chrome for Developers
Where’s the Designer? #AskPolymer -- Polycasts #31
Chrome for Developers
Jake Beats Wikipedia - HTTP203
Chrome for Developers
Supercharged Observers! -- Polycasts #32
Chrome for Developers
Jai's Web blog - Supercharged
Chrome for Developers
Windows Command-line Tooling, Totally Tooling Tips (S2, Ep4)
Chrome for Developers
What about internationalization? #AskPolymer -- Polycasts #33
Chrome for Developers
Developing for Billions (Chrome Dev Summit 2015)
Chrome for Developers
Google+ Performance Improvement Comparison
Chrome for Developers
Deploying HTTPS: The Green Lock and Beyond (Chrome Dev Summit 2015)
Chrome for Developers
Progressive Web Apps (Chrome Dev Summit 2015)
Chrome for Developers
Instant Loading with Service Workers (Chrome Dev Summit 2015)
Chrome for Developers
Increase Engagement with Web Push Notifications (Chrome Dev Summit 2015)
Chrome for Developers
Engaging with the Real World: Web Bluetooth and Physical Web (Chrome Dev Summit 2015)
Chrome for Developers
Asking for Permission: respectful, opinionated UI (Chrome Dev Summit 2015)
Chrome for Developers
Polymer - State of the Union (Chrome Dev Summit 2015)
Chrome for Developers
Building Progressive Web Apps with Polymer (Chrome Dev Summit 2015)
Chrome for Developers
Introduction to RAIL (Chrome Dev Summit 2015)
Chrome for Developers
DevTools in 2015: Authoring to the max (Chrome Dev Summit 2015)
Chrome for Developers
RAIL in the real world (Chrome Dev Summit 2015)
Chrome for Developers
#ChromeDevSummit talks are up - W00T! -- Polycast #34
Chrome for Developers
V8 Performance from the Driver's Seat (Chrome Dev Summit 2015)
Chrome for Developers
Quantify and improve real-world RAIL (Chrome Dev Summit 2015)
Chrome for Developers
Owning your performance: RAIL (Chrome Dev Summit 2015)
Chrome for Developers
HTTP/2 101 (Chrome Dev Summit 2015)
Chrome for Developers
Leadership Panel (Chrome Dev Summit 2015)
Chrome for Developers
Build Processes, Totally Tooling Tips (S2, Ep 5)
Chrome for Developers
Accessibility (Chrome Dev Summit 2015)
Chrome for Developers
Binding to Arrays -- Polycasts #35
Chrome for Developers
HTTP2 - HTTP203
Chrome for Developers
Chrome 47: Splash Screens, requestIdleCallback and better desktop notifications (New in Chrome)
Chrome for Developers
Call For Submissions - Supercharged
Chrome for Developers
Cross Device Testing, Totally Tooling Tips (S2 Ep6)
Chrome for Developers
Testing AJAX with Web Component Tester -- Polycasts #37
Chrome for Developers
Slack: Extended Xmas Special - Supercharged
Chrome for Developers
Browser testing with Travis & Sauce Labs -- Polycasts #38
Chrome for Developers
Optimize for production with Vulcanize -- Polycasts #39
Chrome for Developers
Highlights from Chrome Dev Summit 2015
Chrome for Developers
Chrome 48: Custom buttons in notifications, DevTools Security panel, and Presentation mode
Chrome for Developers
Crisper: Protecting your Polymer app with CSP -- Polycasts #40
Chrome for Developers
How do I use Sass with Polymer? #AskPolymer -- Polycasts #41
Chrome for Developers
Colors – DevTools Tonight #0 (Pilot)
Chrome for Developers
More on: JavaScript Fundamentals
View skill →
🎓
Tutor Explanation
DeepCamp AI