Skip to content

Instantly share code, notes, and snippets.

@hkan
hkan / macro.php
Last active March 8, 2019 21:06
TestResponse::assertViewHasDeep assertion
<?php
use PHPUnit\Framework\Assert as PHPUnit;
use Illuminate\Support\Arr;
use Illuminate\Foundation\Testing\TestResponse;
use Illuminate\Database\Eloquent\Model;
TestResponse::macro('assertViewHasDeep', function ($key, $value = null) {
$this->ensureResponseHasView();
@hkan
hkan / text.js
Created April 28, 2020 17:23
Alpine's x-text directive improved to support contenteditable elements
export function handleTextDirective(el, output, expression) {
// If nested model key is undefined, set the default value to empty string.
if (output === undefined && expression.match(/\./).length) {
output = ''
}
let selection
let anchorNode
let position
let isElBeingEdited