<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: Playing with Dark Magic</title>
	<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic/</link>
	<description>Comments on MetaFilter post Playing with Dark Magic</description>
	<pubDate>Tue, 18 Jan 2011 16:08:19 -0800</pubDate>
	<lastBuildDate>Tue, 18 Jan 2011 16:08:19 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Playing with Dark Magic</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic</link>	
		<description>&lt;a href="http://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/"&gt;What the Heck is Shadow DOM?&lt;/a&gt; Browser developers realized that coding the appearance and behavior of HTML elements completely by hand is a) hard and b) silly. So they sort of cheated. They created a boundary between what you, the Web developer can reach and what&apos;s considered implementation details, thus inaccessible to you. The browser however, can traipse across this boundary at will.</description>
		<guid isPermaLink="false">post:www.metafilter.com,2011:site.99648</guid>
		<pubDate>Tue, 18 Jan 2011 16:00:22 -0800</pubDate>
		<dc:creator>netbros</dc:creator>		<category>dimitriglazkov</category>		<category>glazkov</category>		<category>dom</category>		<category>browsers</category>		<category>html</category>		<category>elements</category>		<category>shadow</category>		<category>javascript</category>		<category>libraries</category>		<category>document</category>		<category>object</category>		<category>model</category>		<category>css</category>		<category>subtree</category>		<category>webkit</category>		<category>mobile</category>
	</item>	<item>
		<title>By: Artw</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472258</link>	
		<description> WARNING: Pseudocode, not a real API.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472258</guid>
		<pubDate>Tue, 18 Jan 2011 16:08:19 -0800</pubDate>
		<dc:creator>Artw</dc:creator>
	</item>	<item>
		<title>By: cjorgensen</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472280</link>	
		<description>I need a bit more to go on. I read the first half, skimmed the rest. What&apos;s the tweet version take away on why this is cool?</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472280</guid>
		<pubDate>Tue, 18 Jan 2011 16:27:11 -0800</pubDate>
		<dc:creator>cjorgensen</dc:creator>
	</item>	<item>
		<title>By: Artw</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472291</link>	
		<description>As far as i can figure out... some browsers render form elements as nested HTML? But don&apos;t give you a way to mess with it? And he thinks it would be a good idea to mess with it because ???

/shrugs. Possibly I am tired right now, because people are responding in comments as if he has written something reasonable and not the timecubey mess I am reading it as.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472291</guid>
		<pubDate>Tue, 18 Jan 2011 16:32:16 -0800</pubDate>
		<dc:creator>Artw</dc:creator>
	</item>	<item>
		<title>By: mark242</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472295</link>	
		<description>From the article: &lt;i&gt;&quot;The ability to write your widget and not worry about some random selector fiddling with your style seems ... downright intoxicating.&quot;&lt;/i&gt;

Actually, it seems exactly the opposite, more of a nauseating &quot;this is why it takes five revisions in Photoshop to show off our custom &amp;lt;select&amp;gt; widget&quot;.

I appreciate what all the browser developers are doing with regards to native widgets, but this battle was already fought and more-or-less lost after the days of having custom scrollbar colors in IE, Netscape 4, etc.

The moment you start sandboxing UI away from the designer/integrator is the moment you start getting hideous flash scrollbar widgets that serve little purpose other than to confuse and distract your users. I like the ability to style my &quot;Post Comment&quot; button to be yellow, with a little two-pixel bevel. Taking that away from me by only allowing some attributes to be styled via a &quot;Shadow DOM&quot; is basically saying, &quot;well, go ahead and create &amp;lt;input type=&quot;image&quot;&amp;gt; once again because you can&apos;t do what you really want.&quot;

If the author of the article is worried about &quot;some random selector fiddling with your style&quot; then whose fault is it really? The designer who puts in &amp;lt;style&amp;gt; i { font-style: normal; } &amp;lt;/style&amp;gt; or the widget maker?  HTML, and now CSS, has always been a &quot;test visually&quot; language, almost an np-problem, so it makes &lt;i&gt;more&lt;/i&gt; sense to allow the maximum amount of visual styling possible.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472295</guid>
		<pubDate>Tue, 18 Jan 2011 16:33:08 -0800</pubDate>
		<dc:creator>mark242</dc:creator>
	</item>	<item>
		<title>By: Artw</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472305</link>	
		<description>Oh, that&apos;s what he&apos;s trying to do? yeah, that&apos;s a no.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472305</guid>
		<pubDate>Tue, 18 Jan 2011 16:39:51 -0800</pubDate>
		<dc:creator>Artw</dc:creator>
	</item>	<item>
		<title>By: humboldt32</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472308</link>	
		<description>Are we talking about 2 spaces after a period again?</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472308</guid>
		<pubDate>Tue, 18 Jan 2011 16:40:34 -0800</pubDate>
		<dc:creator>humboldt32</dc:creator>
	</item>	<item>
		<title>By: delmoi</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472323</link>	
		<description>&lt;blockquote&gt;&lt;i&gt;With the exception of SVG (more on that later), today&apos;s Web platform offers only one built-in mechanism to isolate one chunk of code from another &#8212; and it ain&apos;t pretty. Yup, I am talking about iframes. For most encapsulation needs, frames are too heavy and restrictive.&lt;/i&gt;&lt;/blockquote&gt;

Yeah... this guy has no idea what he&apos;s talking about.  Javascript is an incredibly flexible language and you can do most OO things with it, although it&apos;s true that it doesn&apos;t have private members... there&apos;s a huge difference between actual &lt;i&gt;secure isolation&lt;/i&gt; between components (which is what iFrames give you) and encapsulation. 

Basically, encapsulation is a way of &lt;b&gt;preventing programming mistakes&lt;/b&gt;.  If you prevent code from accessing parts of other objects then you can change the way an object is implemented in the future, while being sure that your other code won&apos;t break.  And, you can have different implementations at the same time. 

The only difference between Javascript and something like Java and C++ is that Javascript won&apos;t catch your mistakes for you, being a weakly typed language. But there are ways to &apos;cheat&apos; the type system in both Java and C++ if you want. They are not for actual security (In theory, you can&apos;t cheat in java if your running code from an untrusted security context).  But if you do cheat you have to do something &apos;weird&apos;, something that would be unlikely to be used if in normal development.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472323</guid>
		<pubDate>Tue, 18 Jan 2011 16:47:31 -0800</pubDate>
		<dc:creator>delmoi</dc:creator>
	</item>	<item>
		<title>By: Mars Saxman</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472365</link>	
		<description>&lt;i&gt;Taking that away from me by only allowing some attributes to be styled via a &quot;Shadow DOM&quot; is basically saying, &quot;well, go ahead and create  once again because you can&apos;t do what you really want.&quot;&lt;/i&gt;

speaking as a user, I&apos;d really rather you gave up the fantasy that you (designer) get to have complete control over something that is ultimately happening on my computer, and just let the browser draw normal widgets the way the native OS wants to draw them.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472365</guid>
		<pubDate>Tue, 18 Jan 2011 17:04:35 -0800</pubDate>
		<dc:creator>Mars Saxman</dc:creator>
	</item>	<item>
		<title>By: ardgedee</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472400</link>	
		<description>Preventing web developers from making sites that drive users away due to their miserable overdesign is not the purpose of a web browser. In fact, this tends to be a problem that moderates itself without intervention.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472400</guid>
		<pubDate>Tue, 18 Jan 2011 17:24:19 -0800</pubDate>
		<dc:creator>ardgedee</dc:creator>
	</item>	<item>
		<title>By: dubitable</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472426</link>	
		<description>Man, I have enough troubles just getting divs to look the same across browsers.  What is this guy on about?

&lt;em&gt;speaking as a user, I&apos;d really rather you gave up the fantasy that you (designer) get to have complete control over something that is ultimately happening on my computer, and just let the browser draw normal widgets the way the native OS wants to draw them.&lt;/em&gt;

Everyone just needs to relax and go back to what they were doing.  This is a non-starter.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472426</guid>
		<pubDate>Tue, 18 Jan 2011 17:37:20 -0800</pubDate>
		<dc:creator>dubitable</dc:creator>
	</item>	<item>
		<title>By: jsavimbi</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472458</link>	
		<description>Wait, so if I spend an extra $10k and tinker with the engine of my consumer market automobile and blow it out drag racing at the old airstrip on a Friday night, my warranty is voided? What about the spoiler and the running lights?</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472458</guid>
		<pubDate>Tue, 18 Jan 2011 18:05:42 -0800</pubDate>
		<dc:creator>jsavimbi</dc:creator>
	</item>	<item>
		<title>By: Civil_Disobedient</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472472</link>	
		<description>&lt;i&gt;although it&apos;s true that it doesn&apos;t have private members&lt;/i&gt;

That&apos;s not true at all.  All variables declared within the scope of an object&apos;s construction are private, accessible only to other privately-scoped functions in the same object.
&lt;pre&gt;function MyObject() {
  var private = 0;
  this.public = 1;
}
var temp = new MyObject();
alert(temp.private); // undefined
alert(temp.public); // 1
&lt;/pre&gt;</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472472</guid>
		<pubDate>Tue, 18 Jan 2011 18:19:31 -0800</pubDate>
		<dc:creator>Civil_Disobedient</dc:creator>
	</item>	<item>
		<title>By: thsmchnekllsfascists</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472487</link>	
		<description>&lt;em&gt;speaking as a user, I&apos;d really rather you gave up the fantasy that you (designer) get to have complete control over something that is ultimately happening on my computer, and just let the browser draw normal widgets the way the native OS wants to draw them.
&lt;/em&gt;
Yup, that pretty much sums it up.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472487</guid>
		<pubDate>Tue, 18 Jan 2011 18:29:50 -0800</pubDate>
		<dc:creator>thsmchnekllsfascists</dc:creator>
	</item>	<item>
		<title>By: Ad hominem</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472533</link>	
		<description>Not sure what he expects, at a base level input controls are just &lt;a href=&quot;http://blogs.msdn.com/b/oldnewthing/archive/2005/02/11/371042.aspx&quot;&gt; windowless controls&lt;/a&gt;. For a long time people bumped into the fact that select was not implemented as a windowless control, It was impossible to place a div over a visible select control, the select control always displayed on top</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472533</guid>
		<pubDate>Tue, 18 Jan 2011 18:54:35 -0800</pubDate>
		<dc:creator>Ad hominem</dc:creator>
	</item>	<item>
		<title>By: Ad hominem</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472537</link>	
		<description>Oh , a bit farther afield but it is possible to use silverlight in windowed and windowless mode. Windowed mode is faster, in windowless mode you can position DIVs over the plugin.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472537</guid>
		<pubDate>Tue, 18 Jan 2011 18:57:28 -0800</pubDate>
		<dc:creator>Ad hominem</dc:creator>
	</item>	<item>
		<title>By: Pope Guilty</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472564</link>	
		<description>&lt;i&gt;
speaking as a user, I&apos;d really rather you gave up the fantasy that you (designer) get to have complete control over something that is ultimately happening on my computer, and just let the browser draw normal widgets the way the native OS wants to draw them.&lt;/i&gt;

See also the way IGN webpages must be navigated by the mouse, since the keyboard browser controls mysteriously do nothing or return you to the top of the page.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472564</guid>
		<pubDate>Tue, 18 Jan 2011 19:28:21 -0800</pubDate>
		<dc:creator>Pope Guilty</dc:creator>
	</item>	<item>
		<title>By: eriko</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472575</link>	
		<description>&lt;i&gt; The moment you start sandboxing UI away from the designer/integrator is the moment you start getting &lt;/i&gt;

...consistent and clear interfaces that &quot;designers&quot; and &quot;integrators&quot; can&apos;t repeatedly fuck up.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472575</guid>
		<pubDate>Tue, 18 Jan 2011 19:39:52 -0800</pubDate>
		<dc:creator>eriko</dc:creator>
	</item>	<item>
		<title>By: jeffamaphone</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472637</link>	
		<description>Abstraction layers... abstract things?</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472637</guid>
		<pubDate>Tue, 18 Jan 2011 20:24:06 -0800</pubDate>
		<dc:creator>jeffamaphone</dc:creator>
	</item>	<item>
		<title>By: moz</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472644</link>	
		<description>Civil_Disobedient:

&lt;em&gt;That&apos;s not true at all. All variables declared within the scope of an object&apos;s construction are private, accessible only to other privately-scoped functions in the same object.&lt;/em&gt;

I would submit that is not &quot;private&quot; in the sense that most object-oriented frameworks would understand the term.  To declare &quot;var private&quot; in that function would mean that the private variable does not exist anyplace but that function and any code directly contained therein.  In most OO languages, a private variable is one that may be accessed only by class methods which is not the case in your example for javascript.

As someone who does a fair share of programming on the web, there are some things which really demand that you work with the DOM in javascript (the &quot;shadow&quot; DOM, as it were).  It&apos;s the age-old problem: computers are meant to automate things.  Maybe it feels more open to hack some things by hand, but after a while I imagine most wonder to themselves if they aren&apos;t missing the point.

That is not to say anything about people deliberately hiding HTML that they very well could have written by hand in javascript, but you can generally ignore such people as they are clearly deranged.  It may be easier to automate some code in javascript, but it&apos;s not as straightforward as just writing out some HTML if that&apos;s all you need.

A final point to make, if it hasn&apos;t already been made: isn&apos;t this a browser issue more than a bad-programmers-hide-things problem?  I mean, the browser knows what&apos;s in the DOM even if it&apos;s different than what the HTML source would indicate.  There&apos;s nothing that keeps it from showing you in some kind of source view what is actually in the DOM.  (Doesn&apos;t Chrome do this now?)</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472644</guid>
		<pubDate>Tue, 18 Jan 2011 20:31:33 -0800</pubDate>
		<dc:creator>moz</dc:creator>
	</item>	<item>
		<title>By: Ad hominem</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472663</link>	
		<description>I think he is wrong about the webkit video control. He states that it is HTML and CSS in a &quot;shadow dom&quot;. Accoding to &lt;a href=&quot;https://trac.webkit.org/wiki/QtWebKitMediaElementSupport&quot;&gt; this &lt;/a&gt;it is based on &lt;a href=&quot;http://doc.qt.nokia.com/4.4/phonon-videowidget.html&quot;&gt;this&lt;/a&gt;. Reading the &quot;software rendering&quot; portion of the webkit docs this seems like the QT equiv of an &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb775501(v=vs.85).aspx&quot;&gt;owner drawn control&lt;/a&gt;. Is he sure there is a &quot;shadow dom&quot; or just some QT widgets that have some properties accessible to the browser.

Any QT developers around? Webkit is a branch of kthml that famously used QT right?</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472663</guid>
		<pubDate>Tue, 18 Jan 2011 20:40:44 -0800</pubDate>
		<dc:creator>Ad hominem</dc:creator>
	</item>	<item>
		<title>By: Ad hominem</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472664</link>	
		<description>Err I mean KHTML</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472664</guid>
		<pubDate>Tue, 18 Jan 2011 20:41:38 -0800</pubDate>
		<dc:creator>Ad hominem</dc:creator>
	</item>	<item>
		<title>By: zachlipton</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472677</link>	
		<description>&lt;em&gt;But there are ways to &apos;cheat&apos; the type system in both Java and C++ if you want. They are not for actual security (In theory, you can&apos;t cheat in java if your running code from an untrusted security context). But if you do cheat you have to do something &apos;weird&apos;, something that would be unlikely to be used if in normal development.&lt;/em&gt;

Except it&apos;s my experience that sooner or later, every reasonably large Java program starts to use reflection in increasingly unusual ways, usually to implement various design patterns for dynamically creating different types of objects at runtime or to make certain JavaBeans behavior work or to handle serialization or any number of other reasons. In other words, large released Java apps &quot;cheat&quot; the type system all the time.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472677</guid>
		<pubDate>Tue, 18 Jan 2011 20:50:56 -0800</pubDate>
		<dc:creator>zachlipton</dc:creator>
	</item>	<item>
		<title>By: Ad hominem</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472695</link>	
		<description>Agreed, .net also use reflection for some very common things, such as the XmlSerializer class.
Various ORMs such as &lt;a href=&quot;http://community.jboss.org/wiki/HibernateFAQ-PerformanceQA#Okay_so_what_are_the_advantages_of_reflection_then&quot;&gt;hibernate &lt;/a&gt;(according to the FAQ) use reflection extensively. This is all normal development, but I agree with you that if you are using reflection to poke at the internals of a component you are going to get burned.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472695</guid>
		<pubDate>Tue, 18 Jan 2011 21:07:25 -0800</pubDate>
		<dc:creator>Ad hominem</dc:creator>
	</item>	<item>
		<title>By: hattifattener</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472721</link>	
		<description>He&apos;s not talking about encapsulating JavaScript, guys: he&apos;s talking about encapsulating HTML/CSS &quot;code&quot;.

If I want to make a reusable doohickey out of HTML and CSS that gets dropped into a larger web page by somebody else (like, a date-picker or a status-of-your-shopping-cart widget), I have to worry about their CSS selectors reaching in and messing with my rendering, not to mention their JavaScript noticing that my doohickey&apos;s DOM node has all sorts of internal structure and maybe starting to rely on the specific implementation.

So then he points out that a lot of things that web designers think of as simple native controls (like that slider) are actually just DOM subtrees with some kind of encapsulation barrier to make them appear structureless from the outside. And wouldn&apos;t it be nice (he concludes) if there were some way to get similar isolation for arbitrary parts of the page?</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472721</guid>
		<pubDate>Tue, 18 Jan 2011 21:26:46 -0800</pubDate>
		<dc:creator>hattifattener</dc:creator>
	</item>	<item>
		<title>By: zvs</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472737</link>	
		<description>&lt;em&gt;If I want to make a reusable doohickey out of HTML and CSS that gets dropped into a larger web page by somebody else (like, a date-picker or a status-of-your-shopping-cart widget), I have to worry about their CSS selectors reaching in and messing with my rendering&lt;/em&gt;

So, namespace your CSS selectors. Unless you mean &apos;messing with it on purpose&apos;, which is not something you&apos;re going to convince an overzealous web designer is bad.

&lt;em&gt;rely on the specific implementation&lt;/em&gt;

It&apos;s not like you&apos;re able to provide accessors for discrete pieces of your HTML widget. It&apos;s simply the nature of the markup-language beast that the internals of your widget are exposed -- and the hacky pseudoselectors outlined in the article still allow downstreamers to become reliant on your &apos;shadow DOM details&apos;... they merely have to type a few arcane symbols, from the looks of it, and you&apos;re right back where you started.

Meanwhile, someone has to write this silly API and get it implemented across the board. I&apos;m sure that&apos;s going to come down the web standards conveyor belt even quicker than the last ten things I was promised.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472737</guid>
		<pubDate>Tue, 18 Jan 2011 21:38:58 -0800</pubDate>
		<dc:creator>zvs</dc:creator>
	</item>	<item>
		<title>By: flabdablet</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472821</link>	
		<description>&lt;em&gt;I would submit that is not &quot;private&quot; in the sense that most object-oriented frameworks would understand the term. To declare &quot;var private&quot; in that function would mean that the private variable does not exist anyplace but that function and any code directly contained therein. In most OO languages, a private variable is one that may be accessed only by class methods which is not the case in your example for javascript.&lt;/em&gt;

Spidermonkey disagrees with you:

&lt;pre&gt;
stephen@jellyfish:~$ js
js&amp;gt; function foo() {
 var privateThing = 0;
 this.getPrivateThing = function() { return privateThing; }
 this.setprivateThing = function(val) { privateThing = val; }
 this.visibleThing = 2;
}
js&amp;gt; var bar = new foo();
js&amp;gt; bar.getPrivateThing();
0
js&amp;gt; bar.setPrivateThing(3);
js&amp;gt; print(bar.getPrivateThing());
3
js&amp;gt; print(bar.privateThing);
undefined
js&amp;gt; print(bar.visibleThing);
2
js&amp;gt; bar.visibleThing = 99
99
js&amp;gt; print(bar.visibleThing);
99
js&amp;gt; var gum = new foo();
js&amp;gt; print(bar.getPrivateThing());
3
js&amp;gt; print(gum.getPrivateThing());
0
js&amp;gt; print(bar.visibleThing);
99
js&amp;gt; print(gum.visibleThing);
2
js&amp;gt; ^C
stephen@jellyfish:~$ 
&lt;/pre&gt;</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472821</guid>
		<pubDate>Tue, 18 Jan 2011 23:37:26 -0800</pubDate>
		<dc:creator>flabdablet</dc:creator>
	</item>	<item>
		<title>By: teraflop</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472822</link>	
		<description>Obligatory Douglas Crockford: &lt;a href=&quot;http://www.crockford.com/javascript/private.html&quot;&gt;Private Members in JavaScript&lt;/a&gt;</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472822</guid>
		<pubDate>Tue, 18 Jan 2011 23:37:48 -0800</pubDate>
		<dc:creator>teraflop</dc:creator>
	</item>	<item>
		<title>By: Ad hominem</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472840</link>	
		<description>To be fair access to privateThing is limited to members function foo due to scope.  The closeure  that contains the foo ctor still exists when you call foo&apos;s member functions. This isn&apos;t really what people think of when they think of member variables marked private.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472840</guid>
		<pubDate>Wed, 19 Jan 2011 00:11:57 -0800</pubDate>
		<dc:creator>Ad hominem</dc:creator>
	</item>	<item>
		<title>By: Ad hominem</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472844</link>	
		<description>&lt;em&gt;to members function foo due to scope&lt;/em&gt;

I mean member functions of foo.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472844</guid>
		<pubDate>Wed, 19 Jan 2011 00:14:46 -0800</pubDate>
		<dc:creator>Ad hominem</dc:creator>
	</item>	<item>
		<title>By: delmoi</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3472898</link>	
		<description>Also, if you need truly custom controls, you can write them yourself using HTML+JS, or even &amp;lt;canvas&amp;gt;</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3472898</guid>
		<pubDate>Wed, 19 Jan 2011 02:16:57 -0800</pubDate>
		<dc:creator>delmoi</dc:creator>
	</item>	<item>
		<title>By: flabdablet</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3473080</link>	
		<description>If it walks like a private variable, and it quacks like a private variable, I don&apos;t see how hairsplitting about implementation details disqualifies it.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3473080</guid>
		<pubDate>Wed, 19 Jan 2011 06:55:38 -0800</pubDate>
		<dc:creator>flabdablet</dc:creator>
	</item>	<item>
		<title>By: Rhomboid</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3473231</link>	
		<description>I think most of the people commenting here are misunderstanding his point.  He&apos;s not saying that authors should have more control over styling native controls.  That pony has long left the stable, and if you search you can find all sorts of articles about how to write custom-styled input/select/etc elements.

The place he&apos;s coming from is the standpoint of a Javascript library author, someone writing jQuery UI or the like.  As it is now, if you want to make sure that your widgets and styles don&apos;t clash with other libraries/frameworks, the best you can do is to manually namespace the IDs/classes.  There is no way to prevent some other code in a complex page from walking all over the elements that your library is responsible for, making them render incorrectly.  This is analogous to, but separate from, all the namespace problems that you get when you try to combine two JS libraries and they both want to override Object.prototype to do their magic.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3473231</guid>
		<pubDate>Wed, 19 Jan 2011 08:28:56 -0800</pubDate>
		<dc:creator>Rhomboid</dc:creator>
	</item>	<item>
		<title>By: The Lurkers Support Me in Email</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3473249</link>	
		<description>I see the author&apos;s point: It would be nice if the &lt;a href=&quot;http://jqueryui.com/demos/datepicker/#inline&quot;&gt;jQuery UI Calendar&lt;/a&gt; I placed on my page wouldn&apos;t display like crap because I specified a generic &lt;code&gt;td { background-color: gray; }&lt;/code&gt; style that &lt;em&gt;wasn&apos;t intended&lt;/em&gt; to apply to the packageable widgets I use. The &quot;shadow DOM&quot; is basically way for a DOM element to say &quot;do not cascade styles down this branch of the tree&quot;.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3473249</guid>
		<pubDate>Wed, 19 Jan 2011 08:37:15 -0800</pubDate>
		<dc:creator>The Lurkers Support Me in Email</dc:creator>
	</item>	<item>
		<title>By: Artw</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3473488</link>	
		<description>The day jQuery UI starts doing this is the day I drop jQuery UI.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3473488</guid>
		<pubDate>Wed, 19 Jan 2011 10:45:33 -0800</pubDate>
		<dc:creator>Artw</dc:creator>
	</item>	<item>
		<title>By: Artw</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3473493</link>	
		<description>And doing something like &lt;code&gt;td { background-color: gray; } &lt;/code&gt; is just asking for trouble - even without JQuery UI. If you&apos;re putting a lot of specific styling in selectors for things like TD, DIV and SPAN I&apos;d be surprised if you&apos;re not having to put in classes for all kinds of special cases that have a  bunch of !important stuff in them, even before any UI libraries.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3473493</guid>
		<pubDate>Wed, 19 Jan 2011 10:48:48 -0800</pubDate>
		<dc:creator>Artw</dc:creator>
	</item>	<item>
		<title>By: bonaldi</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3473702</link>	
		<description>hattifattener and Rhomboid have it: He&apos;s talking about extending the same sort of privilege that browser makers have in being able to protect the appearance of their elements out to framework authors. 

For every ArtW there are 20 HTML authors who ask for trouble. Wouldn&apos;t it be nice if a framework could meet them halfway, offering a set of widgets as protected from inadvertent tampering as the OS elements are?

I realise the answer is of course &quot;fuck off, they should drop everything and spend 9 years in Tibet learning how to do it properly before daring to knock up their quick and dirty&quot; which is the attitude that will also ensure this will never happen.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3473702</guid>
		<pubDate>Wed, 19 Jan 2011 12:54:49 -0800</pubDate>
		<dc:creator>bonaldi</dc:creator>
	</item>	<item>
		<title>By: Artw</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3473944</link>	
		<description>I think that&apos;d be a case of a solution that&apos;s far, far worse than the problem when there is an abundance of other solutions available, and that won&apos;t even cure all of the problems you are likely to be caused if you are insistent on coding like that.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3473944</guid>
		<pubDate>Wed, 19 Jan 2011 15:10:10 -0800</pubDate>
		<dc:creator>Artw</dc:creator>
	</item>	<item>
		<title>By: weston</title>
		<link>http://www.metafilter.com/99648/Playing-with-Dark-Magic#3474025</link>	
		<description>Artw, I get where you&apos;re coming from. Most of the time, it&apos;s a &lt;em&gt;feature&lt;/em&gt; that you can style down as far as you like in the DOM tree and having developers seal stuff off arbitrarily would be annoying (much like it&apos;s annoying when certain stripes of OOP enthusiasts are more enthusiastic about their &lt;code&gt;final&lt;/code&gt; and &lt;code&gt;private&lt;/code&gt; declarations than they are about actually writing classes/objects that are so well-considered that nobody cares to subclass or poke around inside). 

But there are reasons why we isolate code into modules / objects / whatever when we&apos;re writing code in Real Programming Languages (TM), and I think some of those reasons travel well into the world of collaborative styling/markup projects. If you&apos;ve ever worked on, say, a big ol&apos; hacked Wordpress Install where there are 15 different style sheets created by 20 different authors  (not to mention, of course, the additional handful of inline style declarations that go on for 2-3 pages each)... it&apos;s sure easy to think that it would indeed be convenient sometimes if there were some way to isolate rulesets. Or at least say &quot;start me over&quot; without having to re-specify a rule every last default for the browser all over again, or having to pour &lt;code&gt;!important&lt;/code&gt; all over everything, or start adding additional selectors for the sole purpose of manipulating specificity weights. 

So, maybe something like:

&lt;code&gt;&lt;pre&gt;div.someclass#myspecialdombranch {
   default-ruleset: browser;
}&lt;/pre&gt;&lt;/code&gt;
In essence, a &quot;reset&quot; for a given branch of the DOM tree. 

There&apos;s some question in my mind whether you&apos;d really want a &quot;protect me from all outside delcarations&quot; kind of rule, or just a &quot;start over&quot; (the former is the one for I&apos;d worry about abuse, the latter might be too weak unless you&apos;ve got control of attached style declarations or want to (again) resort to the extra &lt;code&gt;!important&lt;/code&gt;s or specificity formulation). But yeah, I can see how this might be really helpful, particularly in a group context.</description>
		<guid isPermaLink="false">comment:www.metafilter.com,2011:site.99648-3474025</guid>
		<pubDate>Wed, 19 Jan 2011 16:18:43 -0800</pubDate>
		<dc:creator>weston</dc:creator>
	</item>
	</channel>
</rss>
