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

TypeError in strict mode #139

Merged
merged 1 commit into from
Jan 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/alpine.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/alpine.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default class Component {
const setWasSuccessful = Reflect.set(obj, property, value)

// Don't react to data changes for cases like the `x-created` hook.
if (self.pauseReactivity) return
if (self.pauseReactivity) return setWasSuccessful

debounce(() => {
self.updateElements(self.$el)
Expand Down
30 changes: 30 additions & 0 deletions test/strict-mode.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Alpine from 'alpinejs'
import { wait } from '@testing-library/dom'

global.MutationObserver = class {
observe() {}
}

test('Proxy does not error in strict mode when reactivity is suspended', async () => {
"use strict"

global.statCounter = function () {
return {
count: 0,
init() {
this.count = 1200;
}
}
}
document.body.innerHTML = `
<div class="my-48">
<div x-data="statCounter()" x-init="init()">
<span x-text="count"></span>
</div>
</div>
`

Alpine.start()

await wait(() => { expect(document.querySelector('span').innerText).toEqual(1200) })
})