Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backlog #2

Open
18 of 33 tasks
fritx opened this issue Dec 24, 2016 · 4 comments
Open
18 of 33 tasks

Backlog #2

fritx opened this issue Dec 24, 2016 · 4 comments

Comments

@fritx
Copy link
Owner

fritx commented Dec 24, 2016

@huangruichang
Copy link

very nice

@fritx
Copy link
Owner Author

fritx commented Dec 26, 2016

nice 🍻 @huangruichang

@fritx fritx mentioned this issue Feb 10, 2017
@fritx
Copy link
Owner Author

fritx commented Mar 21, 2017

  • getPrecedingRange bug
// http://stackoverflow.com/questions/15157435/get-last-character-before-caret-position-in-javascript
export function getPrecedingRange() {
  const r = getRange()
  if (r) {
    const range = r.cloneRange()
    range.collapse(true)
    // 修复 "空格+表情+空格+@" range报错 应设(endContainer, 0)
    // stackoverflow上的这段代码有bug
    // var el = closest(range.endContainer, d => d.contentEditable)
    // range.setStart(el, 0)
    range.setStart(range.endContainer, 0)
    return range
  }
}

error stack was:

Uncaught DOMException: Failed to execute 'setStart' on 'Range':
The offset 3 is larger than or equal to the node's length (2).
    at fn (eval at <anonymous> (http://localhost:8081/dist/demo.js:1010:1), <anonymous>:279:11)

@fritx
Copy link
Owner Author

fritx commented Mar 29, 2017

  • vue2 => vue1:

  • webpack boilerplate

# package.json
   "peerDependencies": {
-    "vue": "2.x"
+    "vue": "1.x"
   },
   "devDependencies": {
     "babel-core": "^6.0.0",
     "babel-loader": "^6.0.0",
+    "babel-plugin-transform-runtime": "^6.0.0",
     "babel-preset-es2015": "^6.0.0",
     "babel-preset-stage-0": "^6.16.0",
     // ...
-    "vue": "^2.1.0",
-    "vue-loader": "^10.3.0",
+    "vue": "^1.0.28",
+    "vue-hot-reload-api": "^1.2.0",
+    "vue-html-loader": "^1.0.0",
+    "vue-loader": "^8.2.1",
     "vue-style-loader": "^1.0.0",
-    "vue-template-compiler": "^2.2.4",
-    "webpack": "^2.1.0-beta.25",
-    "webpack-dev-server": "^2.1.0-beta.9"
+    "webpack": "^1.12.2",
+    "webpack-dev-server": "^1.12.0"
   }
# .babelrc
-  "presets": [
-    "stage-0",
-    ["es2015", { "modules": false }]
-  ]
+  "presets": ["es2015", "stage-0"],
+  "plugins": ["transform-runtime"],
+  "comments": false
# webpack/*.js
# ...
# main.js
 new Vue({
-  el: '#app',
-  render: h => h(App)
+  el: 'body',
+  components: { App }
 })
# index.html
   <body>
-    <div id="app"></div>
+    <app></app>
     <script src="/dist/demo.js"></script>
   </body>
  • prop nameKey => name-key
[Vue warn]: Possible usage error for prop `namekey` - did you mean `name-key`?
HTML is case-insensitive, remember to use kebab-case for props in templates. (found in component: <at>)
Error: Cannot read property '0' of undefined -- (this.$refs.xx)
-  <div ref="wrap"
+  <div v-el:wrap
  • v-for (item, index) => (index, item)
-  <li v-for="(item, index) in atwho.list"
+  <li v-for="(index, item) in atwho.list"
  • drop "scoped slot": slot[scope] => slot, span[v-text] => span[data-text]
[Vue warn]: Error when evaluating expression "s.item.name":
TypeError: Cannot read property 'item' of undefined (found in component: <app>)
-      <template slot="item" scope="s">
-        <img :src="s.item.avatar">
-        <span v-text="s.item.name"></span>
+      <template slot="item">
+        <img data-src="item.avatar">
+        <span data-text="item.name"></span>
  • "normal slot" dom manipulation: watch+handleStateChange
handleStateChange (state) {
  forEach.call(els, el => {
    const textNode = el.querySelector('[data-text]')
    textNode.textContent = this.itemExpr(item, textExpr)
    const imgNode = el.querySelector('[data-src]')
    imgNode.src = this.itemExpr(item, imgExpr)
  })
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants