Comparar commits
5 Commits
master
...
bo-view-system
| Autor | SHA1 | Data | |
|---|---|---|---|
| 6cd1029253 | |||
| 4356d86214 | |||
| f8820c53fa | |||
| 00ed26e8ab | |||
| dfcce37a0a |
+6
-1
@@ -61,7 +61,12 @@
|
||||
"text-buffer": "^3.4",
|
||||
"theorist": "^1.0.2",
|
||||
"underscore-plus": "^1.6.1",
|
||||
"vm-compatibility-layer": "0.1.0"
|
||||
"vm-compatibility-layer": "0.1.0",
|
||||
"elmer": "^0.0",
|
||||
"Node-bind": "git://github.com/Polymer/NodeBind.git#0.4.2",
|
||||
"observe-js": "git://github.com/Polymer/observe-js.git#0.4.2",
|
||||
"polymer-expressions": "git://github.com/Polymer/polymer-expressions.git#0.4.2",
|
||||
"TemplateBinding": "git://github.com/Polymer/TemplateBinding.git#0.4.2"
|
||||
},
|
||||
"packageDependencies": {
|
||||
"atom-dark-syntax": "0.20.0",
|
||||
|
||||
@@ -52,3 +52,18 @@ describe "the `atom` global", ->
|
||||
it 'loads the default core config', ->
|
||||
expect(atom.config.get('core.excludeVcsIgnoredPaths')).toBe true
|
||||
expect(atom.config.get('editor.showInvisibles')).toBe false
|
||||
|
||||
it 'loads the templating globals', ->
|
||||
jasmineContent = document.body.querySelector('#jasmine-content')
|
||||
Template = require './fixtures/html-template.html'
|
||||
Model = {message: 'test!', number: 10}
|
||||
|
||||
jasmineContent.appendChild(Template.clone())
|
||||
jasmineContent.querySelector('template').model = Model
|
||||
|
||||
waits 0
|
||||
|
||||
runs ->
|
||||
# apparently template rendering is async
|
||||
expect(jasmineContent.querySelector('.test-message').textContent).toBe 'test!'
|
||||
expect(jasmineContent.querySelector('.test-number').textContent).toBe '20'
|
||||
|
||||
externo
+2
@@ -0,0 +1,2 @@
|
||||
<div class="one">text</div>
|
||||
<span class="two">text</span>
|
||||
externo
+4
@@ -0,0 +1,4 @@
|
||||
<template bind="{{}}">
|
||||
<div class="test-message">{{message}}</div>
|
||||
<div class="test-number">{{number * 2}}</div>
|
||||
</template>
|
||||
@@ -0,0 +1,13 @@
|
||||
describe "HTMLRequire", ->
|
||||
it "requires the html file and places it into a document fragment", ->
|
||||
html = require './fixtures/html-require.html'
|
||||
docFragment = html.getDocumentFragment()
|
||||
expect(docFragment.children.length).toBe 2
|
||||
expect(docFragment.querySelector('.one').tagName).toBe 'DIV'
|
||||
|
||||
describe '.clone()', ->
|
||||
it "returns a cloned document fragment", ->
|
||||
html = require './fixtures/html-require.html'
|
||||
docFragment = html.clone()
|
||||
expect(docFragment.children.length).toBe 2
|
||||
expect(docFragment.querySelector('.one').tagName).toBe 'DIV'
|
||||
@@ -180,6 +180,7 @@ class Atom extends Model
|
||||
|
||||
@unsubscribe()
|
||||
@setBodyPlatformClass()
|
||||
@requireTemplatingGlobals()
|
||||
|
||||
@loadTime = null
|
||||
|
||||
@@ -713,3 +714,19 @@ class Atom extends Model
|
||||
|
||||
setBodyPlatformClass: ->
|
||||
document.body.classList.add("platform-#{process.platform}")
|
||||
|
||||
requireTemplatingGlobals: ->
|
||||
require('./html-require').register()
|
||||
|
||||
# This is required by the polymer stuff. It can be noop'd because
|
||||
# Object.observe is built into chrome.
|
||||
global.Platform =
|
||||
performMicrotaskCheckpoint: ->
|
||||
|
||||
require 'Node-bind/src/NodeBind'
|
||||
require 'TemplateBinding/src/TemplateBinding'
|
||||
require 'observe-js'
|
||||
global.esprima = require('polymer-expressions/third_party/esprima/esprima').esprima
|
||||
{PolymerExpressions} = require 'polymer-expressions/src/polymer-expressions'
|
||||
|
||||
HTMLTemplateElement.prototype.bindingDelegate = new PolymerExpressions
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
fs = require 'fs'
|
||||
|
||||
# Public:
|
||||
module.exports =
|
||||
class HTMLRequire
|
||||
@register: ->
|
||||
require.extensions['.html'] = (module, filePath) ->
|
||||
html = fs.readFileSync(filePath, 'utf8')
|
||||
template = document.createElement('template')
|
||||
template.innerHTML = html
|
||||
docFragment = template.content
|
||||
module.exports = new HTMLRequire(template.content)
|
||||
|
||||
constructor: (@documentFragment) ->
|
||||
|
||||
getDocumentFragment: -> @documentFragment
|
||||
|
||||
clone: ->
|
||||
@documentFragment.cloneNode(true)
|
||||
Referência em uma Nova Issue
Bloquear um usuário