-
-
Save valueof/9a6d60e9c15ac4239b3d to your computer and use it in GitHub Desktop.
A piece of ordinary boilerplate JavaScript code (original.js) rewritten using proposed moustache syntax (moustache.fixed.js) and class syntax as implemented in Traceur (moustache.class.js)
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
class Channel { | |
constructor (opts) { | |
/* ... */ | |
} | |
load () { | |
var widget = document.createElement("iframe"); | |
widget.{ | |
style.{ | |
width = "100%"; | |
border = "none"; | |
overflow = "hidden"; | |
display = "none"; | |
}; | |
dataset.{ | |
disqusUid = this.uid; | |
}; | |
allowTransparency = true; // < IE8 iframe transparency | |
frameBorder = 0; | |
width = "100%"; | |
id = "dsq" + this.uid; | |
src = this.target + "#" + this.uid; | |
}; | |
} | |
}; |
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
var Channel = function (opts) { /* ... */ }; | |
Channel.prototype.load = function () { | |
var widget = document.createElement("iframe"); | |
widget.{ | |
style.{ | |
width = "100%"; | |
border = "none"; | |
overflow = "hidden"; | |
display = "none"; | |
}; | |
dataset.{ | |
disqusUid = this.uid; | |
}; | |
allowTransparency = true; // < IE8 iframe transparency | |
frameBorder = 0; | |
width = "100%"; | |
id = "dsq" + this.uid; | |
src = this.target + "#" + this.uid; | |
}; | |
}; |
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
var Channel = function (opts) { /* ... */ }; | |
Channel.prototype.load = function () { | |
var widget = document.createElement("iframe"); | |
widget.{ | |
style.{ | |
width = "100%"; | |
border = "none"; | |
overflow = "hidden"; | |
display = "none"; | |
}; | |
allowTransparency = true; // < IE8 iframe transparency | |
frameBorder = 0; | |
width = "100%"; | |
id = "dsq" + this.uid; | |
data-disqus-uid = this.uid | |
src = this.target + "#" + this.uid; | |
}; | |
}; |
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
var Channel = function (opts) { /* ... */ }; | |
Channel.prototype.load = function () { | |
var widget = document.createElement('iframe'); | |
widget.setAttribute('style', 'width:100%; border:none; overflow:hidden; display:none'); | |
widget.setAttribute('allowTransparency', 'true'); // < IE8 iframe transparency | |
widget.setAttribute('frameBorder', '0'); | |
widget.setAttribute('width', '100%'); | |
widget.setAttribute('id', 'dsq' + this.uid); | |
widget.setAttribute('data-disqus-uid', this.uid); | |
widget.setAttribute('src', this.target + '#' + this.uid); | |
// ... | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@izs: agree on syntax being bad (premature, unjustified, impossible to polyfill, etc.).
@dherman: first, I wonder if we shouldn't just try to standardize Object.extend as the shallow thing, and make it match prototype but handle enumerable accessors too.
Second thought: naming. The set vs. update names do not connote shallow vs. deep. No name that I know of does, so the boring but clear way is Object.deepExtend. Too long? It's not the common case going by existing libraries I know of.
/be